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

Use 'case' instead of if/elif in the line matching logic

This commit is contained in:
Daniel Martí 2014-07-06 11:37:52 +02:00
parent 1bcf7c7ce1
commit 69bb03cd71

View File

@ -30,15 +30,16 @@ if [ ! -d metadata ]; then
fi fi
while read line; do 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 ;;
esac
file=${line##* }
id=${file##*/} id=${file##*/}
id=${id%.txt*} id=${id%.txt*}
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
case "$@" in case "$@" in
*" $id "*) ;; # Middle *" $id "*) ;; # Middle
@ -53,11 +54,10 @@ while read line; do
name= autoname= name= autoname=
while read l; do while read l; do
if [[ "$l" == "Auto Name:"* ]]; then case "$l" in
autoname=${l#*:} 'Auto Name:'*) autoname=${l#*:} ;;
elif [[ "$l" == "Name:"* ]]; then 'Name:'*) name=${l#*:} ;;
name=${l#*:} esac
fi
done < "$file" done < "$file"
if [ -n "$name" ]; then if [ -n "$name" ]; then
@ -74,24 +74,22 @@ while read line; do
onlybuild=true onlybuild=true
newbuild=false newbuild=false
disable=false disable=false
while read l; do while read line; do
if [[ "$l" == *"Maintainer Notes:"* ]]; then case "$line" in
break *'Maintainer Notes:'*) break ;;
fi '-Build:'*) onlybuild=false ;;
if [[ "$l" == "-Build:"* ]]; then '+Build:'*)
onlybuild=false $newbuild && onlybuild=false
elif [[ "$l" == "+Build:"* ]]; then
if $newbuild; then
onlybuild=false
fi
newbuild=true newbuild=true
build=${l#*:} build=${l#*:}
version=${build%%,*} version=${build%%,*}
build=${build#*,} build=${build#*,}
vercode=${build%%,*} vercode=${build%%,*}
elif $newbuild && $onlybuild && [[ "$l" == "+"*"disable="* ]]; then ;;
disable=true '+'*'disable='*)
fi $newbuild && $onlybuild && disable=true
;;
esac
done < <(git diff HEAD -- "$file") done < <(git diff HEAD -- "$file")
if $newbuild && $onlybuild; then if $newbuild && $onlybuild; then
@ -107,9 +105,10 @@ while read line; do
message=${message//\"/\\\"} message=${message//\"/\\\"}
commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v") commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
done < <(git status --porcelain metadata) done < <(git status --porcelain metadata)
[[ -z $commands ]] && exit 0 [ -z "$commands" ] && exit 0
git reset >/dev/null git reset >/dev/null
for cmd in "${commands[@]}"; do for cmd in "${commands[@]}"; do