-
Notifications
You must be signed in to change notification settings - Fork 53
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: merge target branch before commit changes #3406
Conversation
git checkout "${target_branch}" | ||
git checkout "${current_branch}" | ||
# only allow fast-forward merging; exit with non-zero result if there's merging | ||
# conflict. | ||
if [[ $(git merge -m "chore: merge ${target_branch} into ${current_branch}" "${target_branch}") -ne 0 ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way is to always update the branch to main before updating in https://github.com/googleapis/sdk-platform-java/blob/main/.github/scripts/update_googleapis_commit.sh, so that we don't have to deal with potential conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, maybe change in update_googleapis_commit.sh
is better because we only want to merge main in generation PR and other pull requests need manual merge anyway.
git commit -m "${title}" | ||
fi | ||
|
||
unpushed_commit=$(git cherry -v "origin/${current_branch}" | wc -l) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this unpushed commit check meant to ensure? I'm not familiar enough with the cherry-pick subcommands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change, we may have up to two commits: merge commit and change commit.
We want to exit the script if no commit happens (otherwise this will be a infinite loop). git cherry
is a way to find whether the local branch has commits that are not in the remote branch. If we find any such commit, push them to remote branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks. Maybe a small comment in this line may help others as well on how this ensures the remote is synced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a small comment
git commit -m "${title}" | ||
fi | ||
|
||
unpushed_commit=$(git cherry -v "origin/${current_branch}" | wc -l) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks. Maybe a small comment in this line may help others as well on how this ensures the remote is synced?
Quality Gate passed for 'gapic-generator-java-root'Issues Measures |
Quality Gate passed for 'java_showcase_integration_tests'Issues Measures |
In this PR:
Example run: https://github.com/googleapis/sdk-platform-java/actions/runs/12148752357/job/33877902009