1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 22:40:12 +01:00
fdroidserver/fd-commit

120 lines
2.7 KiB
Plaintext
Raw Normal View History

2013-06-18 00:18:38 +02:00
#!/bin/bash
2013-12-30 17:15:27 +01:00
#
# fd-commit - part of the FDroid server tools
2013-09-18 00:11:35 +02:00
# Commits updates to apps, allowing you to edit the commit messages
2013-12-30 17:15:27 +01:00
#
2014-01-28 14:07:19 +01:00
# Copyright (C) 2013-2014 Daniel Martí <mvdan@mvdan.cc>
2013-12-30 17:15:27 +01:00
#
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# 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/>.
2013-09-18 00:11:35 +02:00
commands=()
if [ ! -d metadata ]; then
2014-02-13 08:17:58 +01:00
if [ -d ../metadata ]; then
cd ..
else
echo "No metadata files found!"
exit 2
fi
fi
2013-06-18 00:18:38 +02:00
while read line; do
2014-04-28 23:48:12 +02:00
if [[ "$line" == *\?\?*metadata/*.txt ]]; then
2014-04-28 23:36:32 +02:00
new=true
elif [[ "$line" == *M*metadata/*.txt ]]; then
new=false
fi
file=${line##* }
2014-04-28 23:36:32 +02:00
id=${file##*/}
id=${id%.txt*}
if [ $# -gt 0 ]; then
found=false
for arg in "$@"; do
if [ "$id" == "$arg" ]; then
found=true
break
fi
2014-04-28 23:36:32 +02:00
done
$found || continue
fi
2014-04-28 23:36:32 +02:00
[ -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
2014-04-28 23:36:32 +02:00
done < "$file"
if [ -n "$name" ]; then
fullname="$name"
elif [ -n "$autoname" ]; then
fullname="$autoname"
else
fullname="$id"
fi
2014-04-28 23:36:32 +02:00
if $new; then
message="New app: $fullname"
else
onlybuild=true
2013-12-31 10:18:04 +01:00
newbuild=false
2014-01-28 16:59:27 +01:00
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
2013-12-31 10:18:04 +01:00
newbuild=true
build=${l#*:}
version=${build%%,*}
build=${build#*,}
vercode=${build%%,*}
2014-01-28 16:59:27 +01:00
elif $newbuild && $onlybuild && [[ "$l" == "+"*"disable="* ]]; then
disable=true
fi
done < <(git diff HEAD -- "$file")
if $newbuild && $onlybuild; then
if $disable; then
message="Don't update $fullname to $version ($vercode)"
else
message="Update $fullname to $version ($vercode)"
fi
2013-12-31 10:18:04 +01:00
else
message="$fullname:"
fi
fi
2014-04-28 23:36:32 +02:00
message=${message//\"/\\\"}
commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
done < <(git status --porcelain metadata)
2013-07-02 14:39:56 +02:00
[[ -z $commands ]] && exit 0
2014-01-15 10:12:47 +01:00
git reset >/dev/null
for cmd in "${commands[@]}"; do
eval "$cmd"
2014-01-15 10:12:47 +01:00
git reset >/dev/null
done