workstation: session-launch freshen follows the checked-out branch (not just master)
Viktor asked to log Anca into her GitHub account so she can develop on the devvm and deploy her apps through the existing CI/CD. Her GitHub repos (Plotting-Your-Dream-Book, travel, My-Wardrobe — now cloned into her ~/code workspace) default to main, and the launcher freshen only fast-forwarded master, silently skipping them. ff the current branch's upstream instead — same safety gates (on a branch, clean tree, upstream configured, ff-only). Single-layout infra clones behave identically. [ci skip]
This commit is contained in:
parent
de1d8b7bf3
commit
5f7c2964ac
1 changed files with 5 additions and 3 deletions
|
|
@ -26,10 +26,12 @@ cd "$HOME/code" 2>/dev/null || cd "$HOME"
|
||||||
# 10s fetch cap per repo so an offline remote never stalls the launch.
|
# 10s fetch cap per repo so an offline remote never stalls the launch.
|
||||||
freshen_repo() {
|
freshen_repo() {
|
||||||
GIT_TERMINAL_PROMPT=0 timeout 10 git -C "$1" fetch --all --prune --quiet 2>/dev/null || true
|
GIT_TERMINAL_PROMPT=0 timeout 10 git -C "$1" fetch --all --prune --quiet 2>/dev/null || true
|
||||||
if [ "$(git -C "$1" symbolic-ref --short -q HEAD)" = master ] \
|
# ff whatever branch is checked out (master, main, ...) when that is provably
|
||||||
|
# safe: on a branch, clean tree, upstream configured. Never rebases/merges.
|
||||||
|
if [ -n "$(git -C "$1" symbolic-ref --short -q HEAD)" ] \
|
||||||
&& [ -z "$(git -C "$1" status --porcelain 2>/dev/null)" ] \
|
&& [ -z "$(git -C "$1" status --porcelain 2>/dev/null)" ] \
|
||||||
&& git -C "$1" rev-parse --verify -q 'master@{upstream}' >/dev/null 2>&1; then
|
&& git -C "$1" rev-parse --verify -q '@{upstream}' >/dev/null 2>&1; then
|
||||||
git -C "$1" merge --ff-only 'master@{upstream}' >/dev/null 2>&1 || true
|
git -C "$1" merge --ff-only '@{upstream}' >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
if [ -d "$HOME/code/.git" ]; then
|
if [ -d "$HOME/code/.git" ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue