chiark / gitweb /
Fix the copyright notice in gpgsign.py
[fdroidserver.git] / fd-commit
index be62a049707d3e4c6e9eb66be1adfa20d529f3e5..e4012de58838535d0bd1da8186ef026aaa003e57 100755 (executable)
--- a/fd-commit
+++ b/fd-commit
@@ -3,7 +3,7 @@
 # fd-commit - part of the FDroid server tools
 # Commits updates to apps, allowing you to edit the commit messages
 #
-# Copyright (C) 2013 Daniel Martí <mvdan@mvdan.cc>
+# Copyright (C) 2013-2014 Daniel Martí <mvdan@mvdan.cc>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published by
 commands=()
 
 if [ ! -d metadata ]; then
-       [ -d ../metadata ] && cd .. || { echo "No metadata files found!"; exit 2; }
+       if [ -d ../metadata ]; then
+               cd ..
+       else
+               echo "No metadata files found!"
+               exit 2
+       fi
 fi
 
 while read line; do
-       if [[ "$line" == *M*metadata/*.txt ]]; then
-               file=${line##* }
-
-               id=${file##*/}
-               id=${id%.txt*}
-               if [ $# -gt 0 ]; then
-                       found=false
-                       for arg in "$@"; do
-                               if [ "$id" == "$arg" ]; then
-                                       found=true
-                                       break
-                               fi
-                       done
-                       $found || continue
-               fi
-
-               [ -d metadata/$id ] && extra=metadata/$id || extra=
+       if [[ "$line" == *\?\?*metadata/*.txt ]]; then
+               new=true
+       elif [[ "$line" == *M*metadata/*.txt ]]; then
+               new=false
+       fi
+       file=${line##* }
 
-               name= autoname=
-               while read l; do
-                       if [[ "$l" == "Auto Name:"* ]]; then
-                               autoname=${l##*:}
-                       elif [[ "$l" == "Name:"* ]]; then
-                               name=${l##*:}
+       id=${file##*/}
+       id=${id%.txt*}
+       if [ $# -gt 0 ]; then
+               found=false
+               for arg in "$@"; do
+                       if [ "$id" == "$arg" ]; then
+                               found=true
+                               break
                        fi
-               done < "$file"
+               done
+               $found || continue
+       fi
 
-               if [ -n "$name" ]; then
-                       fullname="$name ($id)"
-               elif [ -n "$autoname" ]; then
-                       fullname="$autoname ($id)"
-               else
-                       fullname="$id"
+       [ -d metadata/$id ] && extra=metadata/$id || extra=
+
+       name= autoname=
+       while read l; do
+               if [[ "$l" == "Auto Name:"* ]]; then
+                       autoname=${l#*:}
+               elif [[ "$l" == "Name:"* ]]; then
+                       name=${l#*:}
                fi
+       done < "$file"
+
+       if [ -n "$name" ]; then
+               fullname="$name"
+       elif [ -n "$autoname" ]; then
+               fullname="$autoname"
+       else
+               fullname="$id"
+       fi
 
+       if $new; then
+               message="New app: $fullname"
+       else
+               onlybuild=true
                newbuild=false
+               disable=false
                while read l; do
-                       if [[ "$l" == "+Build:"* ]]; then
+                       if [[ "$l" == *"Maintainer Notes:"* ]]; then
+                               break
+                       fi
+                       if [[ "$l" == "-Build:"* ]]; then
+                               onlybuild=false
+                       elif [[ "$l" == "+Build:"* ]]; then
+                               if $newbuild; then
+                                       onlybuild=false
+                               fi
                                newbuild=true
                                build=${l#*:}
                                version=${build%%,*}
                                build=${build#*,}
                                vercode=${build%%,*}
+                       elif $newbuild && $onlybuild && [[ "$l" == "+"*"disable="* ]]; then
+                               disable=true
                        fi
                done < <(git diff HEAD -- "$file")
 
-               if $newbuild ; then
-                       message="Update $fullname to $version ($vercode)"
+               if $newbuild && $onlybuild; then
+                       if $disable; then
+                               message="Don't update $fullname to $version ($vercode)"
+                       else
+                               message="Update $fullname to $version ($vercode)"
+                       fi
                else
                        message="$fullname:"
                fi
-
-               message=${message//\"/\\\"}
-               commands+=("git commit -m \"$message\" -e -v -- $file $extra")
        fi
-done < <(git status --porcelain)
 
+       message=${message//\"/\\\"}
+       commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
+done < <(git status --porcelain metadata)
+
+[[ -z $commands ]] && exit 0
+
+git reset >/dev/null
 for cmd in "${commands[@]}"; do
        eval "$cmd"
+       git reset >/dev/null
 done