1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-06 11:00:13 +02:00

Rewrite fd-commit in POSIX Shell

This commit is contained in:
Daniel Martí 2014-07-05 13:01:17 +02:00
parent 7d07e52e1f
commit 62ba9dc07e

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
#
# 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 <http://www.gnu.org/licenses/>.
commands=()
commands=""
if [ ! -d metadata ]; then
if [ -d ../metadata ]; then
@ -30,15 +30,17 @@ if [ ! -d metadata ]; then
fi
while read line; do
if [[ "$line" == *\?\?*metadata/*.txt ]]; then
new=true
elif [[ "$line" == *M*metadata/*.txt ]]; then
new=false
fi
file=${line##* }
[ -z "$line" ] && continue
case "$line" in
*\?\?*metadata/*.txt) new=true ;;
*M*metadata/*.txt) new=false ;;
esac
file=${line##* }
id=${file##*/}
id=${id%.txt*}
if [ $# -gt 0 ]; then
found=false
for arg in "$@"; do
@ -54,11 +56,10 @@ while read line; do
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#*:} ;;
esac
done < "$file"
if [ -n "$name" ]; then
@ -75,25 +76,26 @@ while read line; do
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
done < <(git diff HEAD -- "$file")
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 $newbuild && $onlybuild; then
if $disable; then
@ -107,13 +109,18 @@ while read line; do
fi
message=${message//\"/\\\"}
commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
done < <(git status --porcelain metadata)
commands="$commands%%git add -- $file $extra && git commit -m \"$message\" -e -v"
[[ -z $commands ]] && exit 0
done << EOF
$(git status --porcelain metadata)
EOF
[ -z "$commands" ] && exit 0
git reset >/dev/null
for cmd in "${commands[@]}"; do
eval "$cmd"
IFS='%%'
for cmd in $commands; do
[ -z "$cmd" ] && continue
eval $cmd
git reset >/dev/null
done