chore: Split up buildAllCommandsByCfg for readability and modularity #5245
+155
−145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
what
Split up
buildAllCommandsByCfg
into several helper functions.why
I went in to make a change to this function and found it to be very complicated (250+ lines!), so wanted to break it up before working on it. I imagine a lot of logic has been added to this important function over time, seems like it's worth fixing up.
Pulling out the
shouldSkipClone
also made it clear that the repoCfg determined in that function is different from the one used to determine the merged projects. In the previous code that wasn't clear, just a comment saying "this is discarded" that if you missed you might end up reusing accidentally.It also allowed me to refactor the code to make better use of the "happy path" pattern to prevent nested else statements.
tests
I just relied on the existing unit tests, I'm happy to write more if people think that's necessary
references
I'm in the process of working on #859, this refactor will make that work easier.