Codebase list rust-libslirp / run/49047051-381a-4684-afe2-5abd1aee4a89/main dev / sync-pending-branches.sh
run/49047051-381a-4684-afe2-5abd1aee4a89/main

Tree @run/49047051-381a-4684-afe2-5abd1aee4a89/main (Download .tar.gz)

sync-pending-branches.sh @run/49047051-381a-4684-afe2-5abd1aee4a89/main

85c57b0
 
 
 
a07fca2
 
 
 
85c57b0
 
66caf4b
 
3cf49b2
66caf4b
 
 
 
a07fca2
 
 
 
 
85c57b0
a07fca2
 
 
 
 
#!/bin/bash
# Sync remote pending branches locally, and prune merged branches.
set -e

git_hash() {
	git rev-parse -q --verify "$@" || true
}

git fetch origin --prune
PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)"

# delete merged
git branch --merged | tr -d ' ' | grep ^pending- | xargs -trn1 git branch -d
merged=( $(git branch --list -r 'origin/pending-*' --format='%(refname:lstrip=3)' --merged) )
git push origin "${merged[@]/#/:}"

# sync local branches
git branch --list -r 'origin/pending-*' --format='%(refname:lstrip=3)' | while read b; do
	if [ -z "$(git_hash "$b")" ]; then
		git checkout "$b"
	fi
done
git checkout "$PREVBRANCH"
git branch --list 'pending-*'  --format='%(refname:lstrip=2)' | while read b; do
	if [ "$(git_hash "$b")" != "$(git_hash "origin/$b")" ]; then
		echo >&2 "WARNING: Local $b ($(git_hash "$b")) differs from remote $b ($(git_hash "origin/$b"))"
	fi
done