Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Split up buildAllCommandsByCfg for readability and modularity #5245

Merged
merged 1 commit into from
Jan 19, 2025

Conversation

lukemassa
Copy link
Contributor

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.

@lukemassa lukemassa requested review from a team as code owners January 18, 2025 22:31
@lukemassa lukemassa requested review from chenrui333, nitrocode and X-Guardian and removed request for a team January 18, 2025 22:31
@github-actions github-actions bot added the go Pull requests that update Go code label Jan 18, 2025
@dosubot dosubot bot added the refactoring Code refactoring that doesn't add additional functionality label Jan 18, 2025
@lukemassa lukemassa changed the title Split up build all commands by config chore: Split up build all commands by config Jan 18, 2025
@lukemassa lukemassa changed the title chore: Split up build all commands by config chore: Split up buildAllCommandsByCfg for readability and modularity Jan 18, 2025
@lukemassa lukemassa force-pushed the split_up_build_all_commands branch from 5b5fab6 to cf6a0c2 Compare January 19, 2025 18:02
@github-actions github-actions bot added the build Relating to how we build Atlantis label Jan 19, 2025
@lukemassa lukemassa force-pushed the split_up_build_all_commands branch 5 times, most recently from 6aa4ebd to a605577 Compare January 19, 2025 19:36
Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com>
@lukemassa lukemassa force-pushed the split_up_build_all_commands branch from a605577 to 8de7422 Compare January 19, 2025 19:36
Copy link
Contributor

@jamengual jamengual left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks a lot simpler

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 19, 2025
@lukemassa lukemassa merged commit eac2356 into runatlantis:main Jan 19, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Relating to how we build Atlantis go Pull requests that update Go code lgtm This PR has been approved by a maintainer refactoring Code refactoring that doesn't add additional functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants