-
Notifications
You must be signed in to change notification settings - Fork 446
chore: better preflight checks in release.sh #2348
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: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,8 +35,22 @@ if [[ ! $1 =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9] | |||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| git checkout main | ||||||||||||||||||||||||||||||||||||
| git pull | ||||||||||||||||||||||||||||||||||||
| # Pre-flight checks | ||||||||||||||||||||||||||||||||||||
| if [[ "$(git branch --show-current)" != "main" ]]; then | ||||||||||||||||||||||||||||||||||||
| echo "You must be on the main branch to release." >&2 | ||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if [[ -n "$(git status --porcelain)" ]]; then | ||||||||||||||||||||||||||||||||||||
| echo "Working tree is not clean. Commit or stash your changes first." >&2 | ||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| git fetch origin | ||||||||||||||||||||||||||||||||||||
| if [[ -n "$(git diff HEAD origin/main)" ]]; then | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| if [[ -n "$(git diff HEAD origin/main)" ]]; then | |
| if ! git diff --quiet HEAD origin/main; then |
Copilot
AI
Apr 16, 2026
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.
The script now hardcodes origin/main (both in git fetch origin and in the comparison). This is a behavioral regression vs git pull because it will fail for clones that don't have a remote named origin or where main tracks a different upstream. Consider deriving the upstream ref from main’s configured tracking branch (e.g., @{u}) and fetching that, or emitting a clear error if no upstream is configured.
| git fetch origin | |
| if [[ -n "$(git diff HEAD origin/main)" ]]; then | |
| echo "Local main is not up to date with origin/main. Pull first." >&2 | |
| exit 1 | |
| fi | |
| upstream_ref="$(git rev-parse --abbrev-ref --symbolic-full-name '@{u}' 2>/dev/null || true)" | |
| if [[ -z "${upstream_ref}" ]]; then | |
| echo "The main branch has no configured upstream. Configure a tracking branch first." >&2 | |
| exit 1 | |
| fi | |
| upstream_remote="${upstream_ref%%/*}" | |
| git fetch "${upstream_remote}" | |
| if [[ -n "$(git diff HEAD "${upstream_ref}")" ]]; then | |
| echo "Local main is not up to date with ${upstream_ref}. Pull first." >&2 | |
| 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.
The up-to-date check uses
git diff HEAD origin/main, which compares trees only. It can be empty even whenHEADis a different commit thanorigin/main(same tree, different history), causing the release tags to be created from the wrong commit. Consider verifying commit equality (e.g., comparegit rev-parse HEADvsgit rev-parse origin/main, or otherwise ensureHEADexactly matches the remote tip).