From 3dafbd9950f8fc603fd65755d15a6194802adb36 Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Sat, 25 Apr 2026 10:33:56 +0100 Subject: [PATCH 1/2] fix: update_from_template.sh fails on first run Three bugs prevented the script from working correctly: 1. `git pull` after `git checkout -B` fails on a newly created branch with no upstream tracking, killing the script before the template merge ever executes (the critical bug). 2. `git remote add template` fails if the remote already exists from a previous crashed run, since cleanup at the end was never reached. 3. `git checkout --ours pixi.lock` errors when there is no merge conflict on that file. Also extract the template URL and branch name into variables to reduce duplication. --- scripts/update_from_template.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/update_from_template.sh b/scripts/update_from_template.sh index 96d4fb8..c3fb61a 100755 --- a/scripts/update_from_template.sh +++ b/scripts/update_from_template.sh @@ -1,13 +1,17 @@ #! /bin/bash set -eo pipefail +TEMPLATE_URL="https://github.com/blooop/python_template.git" +BRANCH="feature/update_from_template" + git config --global pull.rebase false -git remote add template https://github.com/blooop/python_template.git +git remote remove template 2>/dev/null || true +git remote add template "$TEMPLATE_URL" git fetch --all git checkout main && git pull origin main -git checkout -B feature/update_from_template; git pull +git checkout -B "$BRANCH" git merge template/main --allow-unrelated-histories -m 'feat: pull changes from remote template' -git checkout --ours pixi.lock +git checkout --ours pixi.lock 2>/dev/null || true # regenerate lockfile to match merged pyproject.toml pixi update @@ -15,5 +19,5 @@ git add pixi.lock git diff --cached --quiet || git commit -m 'chore: update pixi.lock after template merge' git remote remove template -git push --set-upstream origin feature/update_from_template +git push --set-upstream origin "$BRANCH" git checkout main From 3620257e84e06c400319468527d6846bc7db9d01 Mon Sep 17 00:00:00 2001 From: Austin Gregg-Smith Date: Sat, 25 Apr 2026 10:56:46 +0100 Subject: [PATCH 2/2] fix: scope git config to local repo, allow env var overrides - Drop --global from `git config pull.rebase false` to avoid mutating the user's global git configuration. - Use ${VAR:-default} for TEMPLATE_URL and BRANCH so they can be overridden via environment variables without editing the script. --- scripts/update_from_template.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/update_from_template.sh b/scripts/update_from_template.sh index c3fb61a..8484267 100755 --- a/scripts/update_from_template.sh +++ b/scripts/update_from_template.sh @@ -1,10 +1,10 @@ #! /bin/bash set -eo pipefail -TEMPLATE_URL="https://github.com/blooop/python_template.git" -BRANCH="feature/update_from_template" +TEMPLATE_URL="${TEMPLATE_URL:-https://github.com/blooop/python_template.git}" +BRANCH="${BRANCH:-feature/update_from_template}" -git config --global pull.rebase false +git config pull.rebase false git remote remove template 2>/dev/null || true git remote add template "$TEMPLATE_URL" git fetch --all