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: merge target branch before commit changes #3406

Merged
merged 15 commits into from
Dec 5, 2024
8 changes: 8 additions & 0 deletions .github/scripts/hermetic_library_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,16 @@ workspace_name="/workspace"
baseline_generation_config="baseline_generation_config.yaml"
message="chore: generate libraries at $(date)"

# there's no local branch when running in GitHub action,
# thus no need to use `git pull`.
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
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

echo "Merge ${target_branch} into ${current_branch} has conflict, exit."
exit 1
fi

# copy generation configuration from target branch to current branch.
git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}"
Expand Down
Loading