#!/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
fi
while read line; do
- if [[ "$line" == *??*metadata/*.txt ]]; then
- new=true
- elif [[ "$line" == *M*metadata/*.txt ]]; then
- new=false
- fi
- file=${line##* }
+ case "$line" in
+ *'??'*'metadata/'*'.txt') new=true ;;
+ *'M'*'metadata/'*'.txt') new=false ;;
+ *) continue ;;
+ esac
+
+ 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
+ case "$@" in
+ *" $id "*) ;; # Middle
+ "$id "*) ;; # Start
+ *" $id") ;; # End
+ "$id") ;; # Alone
+ *) continue ;; # Missing
+ esac
fi
[ -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
+ case "$l" in
+ 'Auto Name:'*) autoname=${l#*:} ;;
+ 'Name:'*) name=${l#*:} ;;
+ 'Summary:'*) break ;;
+ esac
done < "$file"
if [ -n "$name" ]; then
onlybuild=true
newbuild=false
disable=false
- while read l; do
- 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
+ while read line; do
+ case "$line" in
+ '-Build:'*) onlybuild=false ;;
+ '+Build:'*)
+ $newbuild && onlybuild=false
+ newbuild=true
+ build=${line#*:}
+ version=${build%%,*}
+ build=${build#*,}
+ vercode=${build%%,*}
+ ;;
+ '+'*'disable='*)
+ $newbuild && $onlybuild && disable=true
+ ;;
+ esac
done < <(git diff HEAD -- "$file")
if $newbuild && $onlybuild; then
message=${message//\"/\\\"}
commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
+
done < <(git status --porcelain metadata)
-[[ -z $commands ]] && exit 0
+[ -z "$commands" ] && exit 0
git reset >/dev/null
for cmd in "${commands[@]}"; do