2014-07-06 11:29:31 +02:00
|
|
|
#!/bin/bash
|
2013-12-30 17:15:27 +01:00
|
|
|
#
|
2015-06-21 13:51:23 +02:00
|
|
|
# fd-commit - part of the F-Droid 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
|
|
|
|
2014-07-06 11:29:31 +02:00
|
|
|
commands=()
|
2013-09-06 23:36:10 +02:00
|
|
|
|
2013-11-18 15:13:18 +01:00
|
|
|
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
|
2013-11-18 15:13:18 +01:00
|
|
|
fi
|
|
|
|
|
2013-06-18 00:18:38 +02:00
|
|
|
while read line; do
|
2014-07-06 11:29:31 +02:00
|
|
|
|
2014-07-06 11:37:52 +02:00
|
|
|
case "$line" in
|
|
|
|
*'??'*'metadata/'*'.txt') new=true ;;
|
|
|
|
*'M'*'metadata/'*'.txt') new=false ;;
|
2014-08-16 17:51:32 +02:00
|
|
|
*) continue ;;
|
2014-07-06 11:37:52 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
file=${line##* }
|
2014-04-28 23:36:32 +02:00
|
|
|
id=${file##*/}
|
|
|
|
id=${id%.txt*}
|
2014-07-06 11:37:52 +02:00
|
|
|
|
2014-04-28 23:36:32 +02:00
|
|
|
if [ $# -gt 0 ]; then
|
2014-07-05 13:06:01 +02:00
|
|
|
case "$@" in
|
|
|
|
*" $id "*) ;; # Middle
|
|
|
|
"$id "*) ;; # Start
|
|
|
|
*" $id") ;; # End
|
|
|
|
"$id") ;; # Alone
|
|
|
|
*) continue ;; # Missing
|
|
|
|
esac
|
2014-04-28 23:36:32 +02:00
|
|
|
fi
|
2013-11-03 11:50:44 +01:00
|
|
|
|
2014-04-28 23:36:32 +02:00
|
|
|
[ -d metadata/$id ] && extra=metadata/$id || extra=
|
|
|
|
|
|
|
|
name= autoname=
|
|
|
|
while read l; do
|
2014-07-06 11:37:52 +02:00
|
|
|
case "$l" in
|
|
|
|
'Auto Name:'*) autoname=${l#*:} ;;
|
|
|
|
'Name:'*) name=${l#*:} ;;
|
2014-07-06 11:38:32 +02:00
|
|
|
'Summary:'*) break ;;
|
2014-07-06 11:37:52 +02:00
|
|
|
esac
|
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
|
2013-11-03 11:50:44 +01:00
|
|
|
|
2014-04-28 23:36:32 +02:00
|
|
|
if $new; then
|
|
|
|
message="New app: $fullname"
|
|
|
|
else
|
2014-01-28 00:00:34 +01:00
|
|
|
onlybuild=true
|
2013-12-31 10:18:04 +01:00
|
|
|
newbuild=false
|
2014-01-28 16:59:27 +01:00
|
|
|
disable=false
|
2014-07-06 11:37:52 +02:00
|
|
|
while read line; do
|
|
|
|
case "$line" in
|
|
|
|
'-Build:'*) onlybuild=false ;;
|
|
|
|
'+Build:'*)
|
|
|
|
$newbuild && onlybuild=false
|
|
|
|
newbuild=true
|
2014-07-06 23:28:25 +02:00
|
|
|
build=${line#*:}
|
2014-07-06 11:37:52 +02:00
|
|
|
version=${build%%,*}
|
|
|
|
build=${build#*,}
|
|
|
|
vercode=${build%%,*}
|
|
|
|
;;
|
|
|
|
'+'*'disable='*)
|
|
|
|
$newbuild && $onlybuild && disable=true
|
|
|
|
;;
|
|
|
|
esac
|
2014-07-06 11:29:31 +02:00
|
|
|
done < <(git diff HEAD -- "$file")
|
2013-11-03 11:50:44 +01:00
|
|
|
|
2014-01-28 00:00:34 +01:00
|
|
|
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:"
|
2013-10-30 20:17:56 +01:00
|
|
|
fi
|
2013-11-03 11:50:44 +01:00
|
|
|
fi
|
2014-04-28 23:36:32 +02:00
|
|
|
|
|
|
|
message=${message//\"/\\\"}
|
2014-07-06 11:29:31 +02:00
|
|
|
commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
|
2014-07-06 11:37:52 +02:00
|
|
|
|
2014-07-06 11:29:31 +02:00
|
|
|
done < <(git status --porcelain metadata)
|
2013-07-02 14:39:56 +02:00
|
|
|
|
2014-07-06 11:37:52 +02:00
|
|
|
[ -z "$commands" ] && exit 0
|
2014-02-17 08:26:29 +01:00
|
|
|
|
2014-01-15 10:12:47 +01:00
|
|
|
git reset >/dev/null
|
2014-07-06 11:29:31 +02:00
|
|
|
for cmd in "${commands[@]}"; do
|
|
|
|
eval "$cmd"
|
2014-01-15 10:12:47 +01:00
|
|
|
git reset >/dev/null
|
2013-09-06 23:36:10 +02:00
|
|
|
done
|