-#!/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>
+# Copyright (C) 2013-2014 Daniel Marti <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
# 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
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##* }
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=
case "$l" in
'Auto Name:'*) autoname=${l#*:} ;;
'Name:'*) name=${l#*:} ;;
+ 'Summary:'*) break ;;
esac
done < "$file"
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
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