From 1bcf7c7ce1b69e0e2f3c36f110c4a93feb8d8fc3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Sun, 6 Jul 2014 11:29:31 +0200 Subject: [PATCH] Revert "Rewrite fd-commit in POSIX Shell" This reverts commit 62ba9dc07e989ce75b6bd9f971bbb1cec04c4da0. --- fd-commit | 79 +++++++++++++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 43 deletions(-) diff --git a/fd-commit b/fd-commit index 20c84895..678f402a 100755 --- a/fd-commit +++ b/fd-commit @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # fd-commit - part of the FDroid server tools # Commits updates to apps, allowing you to edit the commit messages @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -commands="" +commands=() if [ ! -d metadata ]; then if [ -d ../metadata ]; then @@ -30,17 +30,15 @@ if [ ! -d metadata ]; then fi while read line; do - [ -z "$line" ] && continue - - case "$line" in - *\?\?*metadata/*.txt) new=true ;; - *M*metadata/*.txt) new=false ;; - esac - + if [[ "$line" == *\?\?*metadata/*.txt ]]; then + new=true + elif [[ "$line" == *M*metadata/*.txt ]]; then + new=false + fi file=${line##* } + id=${file##*/} id=${id%.txt*} - if [ $# -gt 0 ]; then case "$@" in *" $id "*) ;; # Middle @@ -55,10 +53,11 @@ while read line; do name= autoname= while read l; do - case "$l" in - 'Auto Name:'*) autoname=${l#*:} ;; - 'Name:'*) name=${l#*:} ;; - esac + if [[ "$l" == "Auto Name:"* ]]; then + autoname=${l#*:} + elif [[ "$l" == "Name:"* ]]; then + name=${l#*:} + fi done < "$file" if [ -n "$name" ]; then @@ -75,26 +74,25 @@ while read line; do onlybuild=true newbuild=false disable=false - while read l; do - case "$l" in - *"Maintainer Notes:"*) break ;; - "-Build:"*) onlybuild=false ;; - "+Build:"*) - $newbuild && onlybuild=false - newbuild=true - build=${l#*:} - version=${build%%,*} - build=${build#*,} - vercode=${build%%,*} - ;; - '+'*"disable="*) - $newbuild && $onlybuild && disable=true - ;; - esac - done << EOF - $(git diff HEAD -- "$file") -EOF + 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 && $onlybuild; then if $disable; then @@ -108,18 +106,13 @@ EOF fi message=${message//\"/\\\"} - commands="$commands%%git add -- $file $extra && git commit -m \"$message\" -e -v" - -done << EOF -$(git status --porcelain metadata) -EOF + 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 -IFS='%%' -for cmd in $commands; do - [ -z "$cmd" ] && continue - eval $cmd +for cmd in "${commands[@]}"; do + eval "$cmd" git reset >/dev/null done -- 2.30.2