Gitfed
bastien-mrq/gitfed/ Commits/ 2babb65

current mode now runs git pull --ff-only itself, guarded against a dirty working tree

Followers redeploying an upstream release no longer need a manual git pull before deploy/update.sh current.

bastien-mrq 2026-07-29 12:57 commit 2babb65c4d9be54b0e071377e0487ea2d72504be parent e314b9c63996c9432f9ede3c951375524fdd3642
1 files changed +24 −11
M deploy/update.sh +24 −11
deploy/update.sh
diff --git a/deploy/update.sh b/deploy/update.sh index 427064a..1cc017a 100755 --- a/deploy/update.sh +++ b/deploy/update.sh @@ -9,12 +9,14 @@ # deploy/update.sh minor # bump minor, same # deploy/update.sh major # bump major, same # deploy/update.sh X.Y.Z # set an explicit version, same -# deploy/update.sh current # build+deploy whatever VERSION already -# # says, no version bump, no git commit, -# # no CHANGELOG check — for redeploying a -# # release you just `git pull`ed rather -# # than authored yourself (see FEDERATION.md -# # / INSTALL.md's "mises à jour" section) +# deploy/update.sh current # git pull (fast-forward only), then +# # build+deploy whatever VERSION ends up +# # saying — no version bump, no commit, +# # no CHANGELOG check. For redeploying +# # releases you don't author yourself +# # (see FEDERATION.md / INSTALL.md's +# # "mises à jour" section). Refuses to +# # run over a dirty working tree. # # Release mode (patch/minor/major/X.Y.Z): add the new version's entry to # CHANGELOG.md yourself first — the script won't guess what changed. It @@ -24,9 +26,10 @@ # FEDERATION.md). Nothing here pushes to your remote, including the tag — # that's a separate `git push <remote> main --tags` afterward. # -# "current" mode assumes VERSION, CHANGELOG.md and deploy/k8s/deployment.yaml -# are already correct (e.g. you just pulled someone else's release) — -# builds and rolls out without touching git at all. +# "current" mode pulls (fast-forward only — it aborts rather than merge +# or rebase for you) then builds and rolls out whatever that leaves in +# VERSION/CHANGELOG.md/deploy/k8s/deployment.yaml. It's the only mode that +# touches git at all before deploying, and only ever a pull — no commits. # # Where this deploys to is never hardcoded — set it before running: # @@ -49,15 +52,25 @@ fi VPS_SRC_DIR="${GITFED_VPS_SRC_DIR:-~/gitfed-src}" NAMESPACE="gitfed" +redeploy_current=0 +if [ "${1:-patch}" = "current" ]; then + redeploy_current=1 + if [ -n "$(git status --porcelain)" ]; then + echo "error: working tree has uncommitted changes — commit or stash them first. 'current' mode won't pull over local changes." >&2 + exit 1 + fi + echo "==> pulling latest" + git pull --ff-only +fi + current="$(cat VERSION)" bump_patch() { IFS=. read -r maj min pat <<<"$1"; echo "$maj.$min.$((pat + 1))"; } bump_minor() { IFS=. read -r maj min _ <<<"$1"; echo "$maj.$((min + 1)).0"; } bump_major() { IFS=. read -r maj _ _ <<<"$1"; echo "$((maj + 1)).0.0"; } -redeploy_current=0 case "${1:-patch}" in - current) redeploy_current=1; new_version="$current" ;; + current) new_version="$current" ;; patch) new_version="$(bump_patch "$current")" ;; minor) new_version="$(bump_minor "$current")" ;; major) new_version="$(bump_major "$current")" ;;