]> git.pld-linux.org Git - packages/rpm-build-tools.git/commitdiff
purge_packages: Check for changes not merged upstream
authorKacper Kornet <draenog@pld-linux.org>
Sat, 23 Mar 2013 18:32:01 +0000 (18:32 +0000)
committerKacper Kornet <draenog@pld-linux.org>
Sun, 24 Mar 2013 23:01:08 +0000 (23:01 +0000)
purge-packages.sh

index 2819921db0f118c4252433071167852cc3607a25..aeced19f7176264c2eed0cb6d9a363e301c5733a 100755 (executable)
@@ -17,6 +17,8 @@ install -d $purgedir
 for pkg in */.git; do
        pkg=${pkg%/.git}
        cd "$pkg"
+       purge='yes'
+
        status=$(git status --porcelain)
        stash=$(git stash list)
 
@@ -24,16 +26,31 @@ for pkg in */.git; do
        if [ -n "$status" ] || [ -n "$stash" ]; then
                cat <<-EOF
                * Package $pkg - Untracked files or stash not empty. Invoke gc
-
                $status
                EOF
+               purge='no'
                git gc
-       else
+       fi
+       git show-ref --heads |\
+       { while read sha1 branch; do
+               short_branch=${branch#refs/heads/}
+               if ! upstream=$(git rev-parse -q --verify $short_branch@{u}) 2>/dev/null; then
+                       echo "* Package $pkg - Branch $short_branch has not defined upstream"
+                       purge='no'
+                       continue
+               fi
+               if [ -n "$(git rev-list "$upstream..$branch")" ]; then
+                       echo "* Package $pkg - Branch $short_branch is not fully merged to its upstream"
+                       purge='no'
+                       continue
+               fi
+       done
+       if [ "$purge" = 'yes' ]; then
                cat <<-EOF
                * Package $pkg - State clean. Removing
                EOF
                mv ../$pkg $purgedir
-       fi
+       fi }
        cd ..
 done
 
This page took 0.030537 seconds and 4 git commands to generate.