Codebase list rust-stfu8 / a07fca2
dev: sync-pending-branches: cleaner output Ximin Luo 2 years ago
1 changed file(s) with 14 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
11 # Sync remote pending branches locally, and prune merged branches.
22 set -e
33
4 git_hash() {
5 git rev-parse -q --verify "$@" || true
6 }
7
48 git fetch origin --prune
59 PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)"
610 git branch --merged | tr -d ' ' | grep ^pending- | xargs -trn1 git branch -d
7 git branch --list -r 'origin/pending-*' --format='%(refname:lstrip=3)' | xargs -trn1 git checkout
11 git branch --list -r 'origin/pending-*' --format='%(refname:lstrip=3)' | while read b; do
12 if [ -z "$(git_hash "$b")" ]; then
13 git checkout "$b"
14 fi
15 done
816 git checkout "$PREVBRANCH"
17 git branch --list 'pending-*' --format='%(refname:lstrip=2)' | while read b; do
18 if [ "$(git_hash "$b")" != "$(git_hash "origin/$b")" ]; then
19 echo >&2 "WARNING: Local $b ($(git_hash "$b")) differs from remote $b ($(git_hash "origin/$b"))"
20 fi
21 done