chiark / gitweb /
handle Queue
[fdroidserver.git] / fd-commit
index 9da979c5076434761b3eeb56535e5385ef3d5ad4..82ca143dd9482c062e88acb919cacc3f48977feb 100755 (executable)
--- a/fd-commit
+++ b/fd-commit
@@ -1,6 +1,6 @@
-#!/bin/sh
+#!/bin/bash
 #
-# fd-commit - part of the FDroid server tools
+# fd-commit - part of the F-Droid server tools
 # Commits updates to apps, allowing you to edit the commit messages
 #
 # Copyright (C) 2013-2014 Daniel Martí <mvdan@mvdan.cc>
@@ -18,7 +18,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-commands=""
+commands=()
 
 if [ ! -d metadata ]; then
        if [ -d ../metadata ]; then
@@ -30,11 +30,11 @@ if [ ! -d metadata ]; then
 fi
 
 while read line; do
-       [ -z "$line" ] && continue
 
        case "$line" in
-               *\?\?*metadata/*.txt) new=true ;;
-               *M*metadata/*.txt) new=false ;;
+               *'??'*'metadata/'*'.txt') new=true ;;
+               *'M'*'metadata/'*'.txt') new=false ;;
+               *) continue ;;
        esac
 
        file=${line##* }
@@ -42,14 +42,13 @@ while read line; do
        id=${id%.txt*}
 
        if [ $# -gt 0 ]; then
-               found=false
-               for arg in "$@"; do
-                       if [ "$id" == "$arg" ]; then
-                               found=true
-                               break
-                       fi
-               done
-               $found || continue
+               case "$@" in
+                       *" $id "*) ;;  # Middle
+                       "$id "*) ;;    # Start
+                       *" $id") ;;    # End
+                       "$id") ;;      # Alone
+                       *) continue ;; # Missing
+               esac
        fi
 
        [ -d metadata/$id ] && extra=metadata/$id || extra=
@@ -59,6 +58,7 @@ while read line; do
                case "$l" in
                        'Auto Name:'*) autoname=${l#*:} ;;
                        'Name:'*) name=${l#*:} ;;
+                       'Summary:'*) break ;;
                esac
        done < "$file"
 
@@ -76,26 +76,22 @@ while read line; do
                onlybuild=true
                newbuild=false
                disable=false
-
-               while read l; do
-                       case "$l" in
-                               *"Maintainer Notes:"*) break ;;
-                               "-Build:"*) onlybuild=false ;;
-                               "+Build:"*)
+               while read line; do
+                       case "$line" in
+                               '-Build:'*) onlybuild=false ;;
+                               '+Build:'*)
                                        $newbuild && onlybuild=false
                                        newbuild=true
-                                       build=${l#*:}
+                                       build=${line#*:}
                                        version=${build%%,*}
                                        build=${build#*,}
                                        vercode=${build%%,*}
                                        ;;
-                               '+'*"disable="*)
+                               '+'*'disable='*)
                                        $newbuild && $onlybuild && disable=true
                                        ;;
                        esac
-               done << EOF
-               $(git diff HEAD -- "$file")
-EOF
+               done < <(git diff HEAD -- "$file")
 
                if $newbuild && $onlybuild; then
                        if $disable; then
@@ -109,18 +105,14 @@ EOF
        fi
 
        message=${message//\"/\\\"}
-       commands="$commands%%git add -- $file $extra && git commit -m \"$message\" -e -v"
+       commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
 
-done << EOF
-$(git status --porcelain metadata)
-EOF
+done < <(git status --porcelain metadata)
 
 [ -z "$commands" ] && exit 0
 
 git reset >/dev/null
-IFS='%%'
-for cmd in $commands; do
-       [ -z "$cmd" ] && continue
-       eval $cmd
+for cmd in "${commands[@]}"; do
+       eval "$cmd"
        git reset >/dev/null
 done