mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-06 19:10:12 +02:00
Rewrite fd-commit in POSIX Shell
This commit is contained in:
parent
7d07e52e1f
commit
62ba9dc07e
69
fd-commit
69
fd-commit
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# fd-commit - part of the FDroid server tools
|
# fd-commit - part of the FDroid server tools
|
||||||
# Commits updates to apps, allowing you to edit the commit messages
|
# 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
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
commands=()
|
commands=""
|
||||||
|
|
||||||
if [ ! -d metadata ]; then
|
if [ ! -d metadata ]; then
|
||||||
if [ -d ../metadata ]; then
|
if [ -d ../metadata ]; then
|
||||||
@ -30,15 +30,17 @@ if [ ! -d metadata ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
while read line; do
|
while read line; do
|
||||||
if [[ "$line" == *\?\?*metadata/*.txt ]]; then
|
[ -z "$line" ] && continue
|
||||||
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
|
||||||
found=false
|
found=false
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
@ -54,11 +56,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
|
||||||
@ -75,25 +76,26 @@ while read line; do
|
|||||||
onlybuild=true
|
onlybuild=true
|
||||||
newbuild=false
|
newbuild=false
|
||||||
disable=false
|
disable=false
|
||||||
|
|
||||||
while read l; do
|
while read l; do
|
||||||
if [[ "$l" == *"Maintainer Notes:"* ]]; then
|
case "$l" 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
|
||||||
done < <(git diff HEAD -- "$file")
|
;;
|
||||||
|
esac
|
||||||
|
done << EOF
|
||||||
|
$(git diff HEAD -- "$file")
|
||||||
|
EOF
|
||||||
|
|
||||||
if $newbuild && $onlybuild; then
|
if $newbuild && $onlybuild; then
|
||||||
if $disable; then
|
if $disable; then
|
||||||
@ -107,13 +109,18 @@ while read line; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
message=${message//\"/\\\"}
|
message=${message//\"/\\\"}
|
||||||
commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
|
commands="$commands%%git add -- $file $extra && git commit -m \"$message\" -e -v"
|
||||||
done < <(git status --porcelain metadata)
|
|
||||||
|
|
||||||
[[ -z $commands ]] && exit 0
|
done << EOF
|
||||||
|
$(git status --porcelain metadata)
|
||||||
|
EOF
|
||||||
|
|
||||||
|
[ -z "$commands" ] && exit 0
|
||||||
|
|
||||||
git reset >/dev/null
|
git reset >/dev/null
|
||||||
for cmd in "${commands[@]}"; do
|
IFS='%%'
|
||||||
eval "$cmd"
|
for cmd in $commands; do
|
||||||
|
[ -z "$cmd" ] && continue
|
||||||
|
eval $cmd
|
||||||
git reset >/dev/null
|
git reset >/dev/null
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user