-
Notifications
You must be signed in to change notification settings - Fork 122
release.sh: fix for the case of multiple tags #1032
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
base: master
Are you sure you want to change the base?
Conversation
./release.sh v0.31.5-beta fails as of tag v0.31.5-beta: tag v0.31.5-beta not checked out This is because it checks the Git tag with `git describe`, but the current commit has multiple tags and `git describe` returns swapserverrpc/v1.0.18 instead of expected v0.31.5-beta. In this commit this edge case is addressed.
Summary of ChangesHello @starius, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request fixes a bug in the release script that occurred when multiple git tags point to the same commit. The change correctly replaces a failing git describe check with a more robust git tag --points-at HEAD piped to grep. Additionally, the regex for parsing git describe-style tags has been improved. The changes are logical and address the issue effectively. I have one suggestion to combine two of the new checks to make the script slightly more efficient in the success path.
| # Ensure the tag exists in the repository. | ||
| if ! git show-ref --verify --quiet "refs/tags/$TAG"; then | ||
| red "tag $TAG not found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Ensure the current commit is tagged with the requested tag, even when | ||
| # multiple tags point at HEAD. | ||
| if ! git tag --points-at HEAD | grep -Fxq "$TAG"; then | ||
| red "tag $TAG not checked out on the current commit" | ||
| exit 1 | ||
| fi |
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.
These two checks for tag existence and for the tag pointing to the current commit can be combined for better efficiency. In the success case (which should be the common path for a release), this refactoring avoids an extra git process invocation. The suggested code first checks if the tag points to HEAD. If that fails, it then checks if the tag exists at all to provide a more specific error message to the user, preserving the current behavior but in a more optimized way.
| # Ensure the tag exists in the repository. | |
| if ! git show-ref --verify --quiet "refs/tags/$TAG"; then | |
| red "tag $TAG not found" | |
| exit 1 | |
| fi | |
| # Ensure the current commit is tagged with the requested tag, even when | |
| # multiple tags point at HEAD. | |
| if ! git tag --points-at HEAD | grep -Fxq "$TAG"; then | |
| red "tag $TAG not checked out on the current commit" | |
| exit 1 | |
| fi | |
| # Ensure the current commit is tagged with the requested tag, even when | |
| # multiple tags point at HEAD. | |
| if ! git tag --points-at HEAD | grep -Fxq "$TAG"; then | |
| # If the tag is not on the current commit, check if it exists at all | |
| # to provide a better error message. | |
| if git show-ref --verify --quiet "refs/tags/$TAG"; then | |
| red "tag $TAG not checked out on the current commit" | |
| else | |
| red "tag $TAG not found" | |
| fi | |
| exit 1 | |
| fi |
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, thank you! 🎉
./release.sh v0.31.5-betafails as of tagv0.31.5-beta:This is because it checks the Git tag with
git describe, but the current commit has multiple tags andgit describereturnsswapserverrpc/v1.0.18instead of expectedv0.31.5-beta.In this commit this edge case is addressed.
Pull Request Checklist
release_notes.mdif your PR contains major features, breaking changes or bugfixes