fix pre-push to compare with main on first push #2605
Merged
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.
Following on from #2546
I noticed it wasn't actually working, the pushes were still taking ages.
It turned out from looking at the output, the AI generated script was assuming there was always an upstream
origin/MY_BRANCH_NAME
branch, but this isn't the case until you push it.This meant a chicken and egg situation where when you pushed your new branch, it would run the command, get a nonzero exit code (128), and therefore run the tests!
This PR changes it to try the
main
branch, if the similarly named origin branch doesn't exist.Even trying main is not bulletproof, as you might have pulled CDK related updates to main and not merged them into your branch. Or you might have fetched them and merged them in to your branch, without updating the
main
branch. But I think this should cover most of our typical use cases in the way that we would expect.Testing
I have tested both of a new branch and an extra push, on both of with and without changes in the CDK folder, and all combinations work as expected.