From a9ab17c8c0f5a63180e5ef20886fc72bae8d3366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 16 Apr 2026 17:17:45 +0200 Subject: [PATCH 1/3] chore: better preflight checks in release.sh --- release.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index b6c4f70e18..79fa7459e6 100755 --- a/release.sh +++ b/release.sh @@ -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 + echo "Local main is not up to date with origin/main. Pull first." >&2 + exit 1 +fi cd caddy/ go get "github.com/dunglas/frankenphp@v$1" From 3f2082ed4e58c3c876da881a2d795722eea41541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 16 Apr 2026 17:31:54 +0200 Subject: [PATCH 2/3] fix: compare commit SHAs instead of diffs for up-to-date check Using git rev-parse ensures we detect divergence even when tree content is identical across different commits, and avoids materializing the full diff output. Co-Authored-By: Claude Opus 4.6 (1M context) --- release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release.sh b/release.sh index 79fa7459e6..227140394f 100755 --- a/release.sh +++ b/release.sh @@ -47,7 +47,7 @@ if [[ -n "$(git status --porcelain)" ]]; then fi git fetch origin -if [[ -n "$(git diff HEAD origin/main)" ]]; then +if [[ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]]; then echo "Local main is not up to date with origin/main. Pull first." >&2 exit 1 fi From 30e2758dc3c5a3bacb721f43660de8167a4f7c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 16 Apr 2026 17:36:33 +0200 Subject: [PATCH 3/3] fix: distinguish behind/ahead/diverged in release preflight check Provides actionable error messages so the user knows whether to pull, push, or rebase when local main doesn't match origin/main. Co-Authored-By: Claude Opus 4.6 (1M context) --- release.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index 227140394f..78262155f8 100755 --- a/release.sh +++ b/release.sh @@ -47,8 +47,16 @@ if [[ -n "$(git status --porcelain)" ]]; then fi git fetch origin -if [[ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]]; then - echo "Local main is not up to date with origin/main. Pull first." >&2 +local_head="$(git rev-parse HEAD)" +remote_head="$(git rev-parse origin/main)" +if [[ "$local_head" != "$remote_head" ]]; then + if git merge-base --is-ancestor HEAD origin/main; then + echo "Local main is behind origin/main. Pull first." >&2 + elif git merge-base --is-ancestor origin/main HEAD; then + echo "Local main is ahead of origin/main. Push your commits or reset to origin/main before releasing." >&2 + else + echo "Local main has diverged from origin/main. Reconcile with pull/rebase/reset before releasing." >&2 + fi exit 1 fi