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