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

Conversation

JoeWang1127
Copy link
Collaborator

@JoeWang1127 JoeWang1127 commented Dec 3, 2024

In this PR:

  • Merge base branch to current branch before updating generation config.

Example run: https://github.com/googleapis/sdk-platform-java/actions/runs/12148752357/job/33877902009

@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Dec 3, 2024
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.

@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Dec 3, 2024
@JoeWang1127 JoeWang1127 marked this pull request as ready for review December 3, 2024 22:19
git commit -m "${title}"
fi

unpushed_commit=$(git cherry -v "origin/${current_branch}" | wc -l)
Copy link
Contributor

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

Copy link
Collaborator Author

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.

Copy link
Contributor

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?

Copy link
Contributor

@diegomarquezp diegomarquezp left a 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)
Copy link
Contributor

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?

Copy link

sonarqubecloud bot commented Dec 5, 2024

Copy link

sonarqubecloud bot commented Dec 5, 2024

Quality Gate Passed Quality Gate passed for 'java_showcase_integration_tests'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@JoeWang1127 JoeWang1127 merged commit 490615b into main Dec 5, 2024
50 checks passed
@JoeWang1127 JoeWang1127 deleted the chore/merge-target-branch branch December 5, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants