2 # Purges packages/ checkouts
3 # - if package has clean state, the dir is removed
4 # - otherwise git gc is called
7 CALL_GC=${CALL_GC:-'no'}
9 topdir=$(rpm -E %_topdir)
10 purgedir=$topdir/purged
13 if [ -d "$purgedir" ]; then
14 echo >&2 "Previous pruge dir exists: $purgedir, remove it to resume"
24 status=$(git status --porcelain)
25 stash=$(git stash list)
27 # FIXME: does not currently handle if some pushes are not made!
28 if [ -n "$status" ] || [ -n "$stash" ]; then
30 * Package $pkg - Untracked files or stash not empty.
34 [ "$CALL_GC" != 'no' ] && git gc
36 git show-ref --heads |\
37 { while read sha1 branch; do
38 short_branch=${branch#refs/heads/}
39 if ! upstream=$(git rev-parse -q --verify $short_branch@{u}) 2>/dev/null; then
40 echo "* Package $pkg - Branch $short_branch has not defined upstream"
44 if [ -n "$(git rev-list "$upstream..$branch")" ]; then
45 echo "* Package $pkg - Branch $short_branch is not fully merged to its upstream"
50 if [ "$purge" = 'yes' ]; then
52 * Package $pkg - State clean. Removing
59 rmdir --ignore-fail-on-non-empty $purgedir
61 # vi:syntax=sh:ts=4:sw=4:noet