chiark / gitweb /
Update gendocs from 2011-04 to 2013-02
[fdroidserver.git] / fd-commit
1 #!/bin/bash
2
3 # Commits updates to apps, allowing you to edit the commit messages
4
5 commands=()
6
7 if [ ! -d metadata ]; then
8         [ -d ../metadata ] && cd .. || { echo "No metadata files found!"; exit 2; }
9 fi
10
11 while read line; do
12         if [[ "$line" == *M*metadata/*.txt ]]; then
13                 file=${line##* }
14                 
15                 id=${file##*/}
16                 id=${id%.txt*}
17                 if [ $# -gt 0 ]; then
18                         found=false
19                         for arg in "$@"; do
20                                 if [ "$id" == "$arg" ]; then
21                                         found=true
22                                         break
23                                 fi
24                         done
25                         $found || continue
26                 fi
27
28                 if [ -d metadata/$id ]; then
29                         extra=metadata/$id
30                 else
31                         extra=
32                 fi
33
34                 name= autoname=
35                 while read l; do
36                         if [[ "$l" == "Auto Name:"* ]]; then
37                                 autoname=${l##*:}
38                         elif [[ "$l" == "Name:"* ]]; then
39                                 name=${l##*:}
40                         fi
41                 done < "$file"
42
43                 if [ -n "$name" ]; then
44                         fullname="$name ($id)"
45                 elif [ -n "$autoname" ]; then
46                         fullname="$autoname ($id)"
47                 else
48                         fullname="$id"
49                 fi
50
51                 newbuild=0
52                 while read l; do
53                         if [[ "$l" == "+Build:"* ]]; then
54                                 newbuild=1
55                                 build=${l#*:}
56                                 version=${build%%,*}
57                                 build=${build#*,}
58                                 vercode=${build%%,*}
59                         fi
60                 done < <(git diff HEAD -- "$file")
61
62                 if [ $newbuild -eq 0 ]; then
63                         message="$fullname:"
64                 else
65                         message="Update $fullname to $version ($vercode)"
66                 fi
67
68                 commands+=("git commit -m '$message' -e -v -- $file $extra")
69         fi
70 done < <(git status --porcelain)
71
72 for cmd in "${commands[@]}"; do
73         eval "$cmd"
74 done
75