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