1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-14 11:00:10 +01:00
fdroidserver/fd-commit
Daniel Martí 778b15322c fd-commit support for disabled updates
Also fix support for replacement builds
2014-01-28 00:00:34 +01:00

102 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
#
# fd-commit - part of the FDroid server tools
# Commits updates to apps, allowing you to edit the commit messages
#
# Copyright (C) 2013 Daniel Martí <mvdan@mvdan.cc>
#
# 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/>.
commands=()
if [ ! -d metadata ]; then
[ -d ../metadata ] && cd .. || { echo "No metadata files found!"; exit 2; }
fi
while read line; do
if [[ "$line" == *M*metadata/*.txt ]]; then
file=${line##* }
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
[ -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
done < "$file"
if [ -n "$name" ]; then
fullname="$name ($id)"
elif [ -n "$autoname" ]; then
fullname="$autoname ($id)"
else
fullname="$id"
fi
onlybuild=true
newbuild=false
while read l; do
if [[ "$l" == "-Build:"* ]]; then
onlybuild=false
elif [[ "$l" == "+Build:"* ]]; then
if $newbuild; then
onlybuild=false
fi
newbuild=true
build=${l#*:}
version=${build%%,*}
build=${build#*,}
vercode=${build%%,*}
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
else
message="$fullname:"
fi
message=${message//\"/\\\"}
commands+=("git add -- $file $extra && git commit -m \"$message\" -e -v")
fi
done < <(git status --porcelain)
git reset >/dev/null
for cmd in "${commands[@]}"; do
eval "$cmd"
git reset >/dev/null
done