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
|
|
|
|
2013-09-06 23:36:10 +02:00
|
|
|
commands=()
|
|
|
|
|
2013-11-18 15:13:18 +01:00
|
|
|
if [ ! -d metadata ]; then
|
|
|
|
[ -d ../metadata ] && cd .. || { echo "No metadata files found!"; exit 2; }
|
|
|
|
fi
|
|
|
|
|
2013-06-18 00:18:38 +02:00
|
|
|
while read line; do
|
2013-11-03 11:50:44 +01:00
|
|
|
if [[ "$line" == *M*metadata/*.txt ]]; then
|
|
|
|
file=${line##* }
|
2013-12-30 17:04:16 +01:00
|
|
|
|
2013-11-03 11:50:44 +01:00
|
|
|
id=${file##*/}
|
|
|
|
id=${id%.txt*}
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
found=false
|
|
|
|
for arg in "$@"; do
|
|
|
|
if [ "$id" == "$arg" ]; then
|
|
|
|
found=true
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
$found || continue
|
|
|
|
fi
|
|
|
|
|
2013-12-31 10:18:04 +01:00
|
|
|
[ -d metadata/$id ] && extra=metadata/$id || extra=
|
2013-11-03 11:50:44 +01:00
|
|
|
|
2013-12-11 17:18:09 +01:00
|
|
|
name= autoname=
|
2013-11-03 11:50:44 +01:00
|
|
|
while read l; do
|
|
|
|
if [[ "$l" == "Auto Name:"* ]]; then
|
2014-02-05 15:33:20 +01:00
|
|
|
autoname=${l#*:}
|
2013-12-02 15:28:30 +01:00
|
|
|
elif [[ "$l" == "Name:"* ]]; then
|
2014-02-05 15:33:20 +01:00
|
|
|
name=${l#*:}
|
2013-11-03 11:50:44 +01:00
|
|
|
fi
|
|
|
|
done < "$file"
|
|
|
|
|
2013-12-02 15:28:30 +01:00
|
|
|
if [ -n "$name" ]; then
|
2014-02-10 10:55:29 +01:00
|
|
|
fullname="$name"
|
2013-12-02 15:28:30 +01:00
|
|
|
elif [ -n "$autoname" ]; then
|
2014-02-10 10:55:29 +01:00
|
|
|
fullname="$autoname"
|
2013-12-02 15:28:30 +01:00
|
|
|
else
|
|
|
|
fullname="$id"
|
|
|
|
fi
|
2013-11-03 11:50:44 +01:00
|
|
|
|
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
|
2013-11-03 11:50:44 +01:00
|
|
|
while read l; do
|
2014-01-28 00:00:34 +01:00
|
|
|
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
|
2013-11-03 11:50:44 +01:00
|
|
|
build=${l#*:}
|
|
|
|
version=${build%%,*}
|
|
|
|
build=${build#*,}
|
|
|
|
vercode=${build%%,*}
|
2014-01-28 16:59:27 +01:00
|
|
|
elif $newbuild && $onlybuild && [[ "$l" == "+"*"disable="* ]]; then
|
2014-01-28 00:00:34 +01:00
|
|
|
disable=true
|
2013-11-03 11:50:44 +01:00
|
|
|
fi
|
|
|
|
done < <(git diff HEAD -- "$file")
|
|
|
|
|
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-09-06 23:36:10 +02:00
|
|
|
|
2013-12-31 18:09:46 +01:00
|
|
|
message=${message//\"/\\\"}
|
2014-01-11 12:40:36 +01:00
|
|
|
commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
|
2013-11-03 11:50:44 +01:00
|
|
|
fi
|
2013-06-18 00:18:38 +02:00
|
|
|
done < <(git status --porcelain)
|
2013-07-02 14:39:56 +02:00
|
|
|
|
2014-01-15 10:12:47 +01:00
|
|
|
git reset >/dev/null
|
2013-09-06 23:36:10 +02:00
|
|
|
for cmd in "${commands[@]}"; do
|
2013-11-03 11:50:44 +01:00
|
|
|
eval "$cmd"
|
2014-01-15 10:12:47 +01:00
|
|
|
git reset >/dev/null
|
2013-09-06 23:36:10 +02:00
|
|
|
done
|