chiark / gitweb /
fd-commit can now take app ids as filter; retab
authorDaniel Martí <mvdan@mvdan.cc>
Sun, 3 Nov 2013 10:50:44 +0000 (11:50 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Sun, 3 Nov 2013 10:50:44 +0000 (11:50 +0100)
completion/bash-completion
fd-commit

index 2ef8fa1be275771bc1c82609085766bb25d344ce..80cdf2be17aa6bd88850646b4bbbce67b020c0bb 100644 (file)
@@ -5,21 +5,21 @@
 # 'fdroid' is aliased automatically, but aliases to it are not. For instance,
 # to alias 'fd' to 'fdroid' and have competion available:
 #
-#   alias fd='fdroid'
-#   complete -F _fdroid fd
+#      alias fd='fdroid'
+#      complete -F _fdroid fd
 #
 # One can use completion on aliased subcommands as follows:
 #
-#   alias fbuild='fdroid build'
-#   complete -F _fdroid_build fbuild
+#      alias fbuild='fdroid build'
+#      complete -F _fdroid_build fbuild
 #
 # There are also completion function for '-p com.some.app' aliases:
 #
-#   alias fbld='fdroid build -v -l -p'
-#   complete -F _fdroid_build_project fbld
+#      alias fbld='fdroid build -v -l -p'
+#      complete -F _fdroid_build_project fbld
 #
-#   alias fcheckup='fdroid checkupdates -v -p'
-#   complete -F _fdroid_checkupdates_project fcheckup
+#      alias fcheckup='fdroid checkupdates -v -p'
+#      complete -F _fdroid_checkupdates_project fcheckup
 #
 # This way, one can simply do 'fbld com.some.app' or 'fcheckup com.some.app'
 
index e1445a475e4b8e3119c042e84f190b15c15a0ea4..9f1a5a2165b0fb86a23069d08b4c9a1be1a6977c 100755 (executable)
--- a/fd-commit
+++ b/fd-commit
@@ -5,41 +5,55 @@
 commands=()
 
 while read line; do
-    if [[ "$line" == *M*metadata/*.txt ]]; then
-        file=${line##* }
-
-        while read l; do
-            [[ "$l" == "Auto Name:"* ]] && name=${l##*:}
-        done < "$file"
-
-        id=${file##*/}
-        id=${id%.txt*}
-        [ -d metadata/$id ] && extra=metadata/$id
-        [ -n "$name" ] && id="$name ($id)"
-
-        newbuild=0
-        while read l; do
-            if [[ "$l" == "+Build:"* ]]; then
-                newbuild=1
-                build=${l#*:}
-                version=${build%%,*}
-                build=${build#*,}
-                vercode=${build%%,*}
-            fi
-        done < <(git diff HEAD -- "$file")
-
-        if [ $newbuild -eq 0 ]
-               then
+       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
+
+               while read l; do
+                       if [[ "$l" == "Auto Name:"* ]]; then
+                               name=${l##*:}
+                               break
+                       fi
+               done < "$file"
+
+               [ -n "$name" ] && id="$name ($id)"
+
+               newbuild=0
+               while read l; do
+                       if [[ "$l" == "+Build:"* ]]; then
+                               newbuild=1
+                               build=${l#*:}
+                               version=${build%%,*}
+                               build=${build#*,}
+                               vercode=${build%%,*}
+                       fi
+               done < <(git diff HEAD -- "$file")
+
+               if [ $newbuild -eq 0 ]; then
                        message="$id:"
                else
                        message="Update $id to $version ($vercode)"
                fi
 
-        commands+=("git commit -m '$message' -e -v -- $file $extra")
-    fi
+               commands+=("git commit -m '$message' -e -v -- $file $extra")
+       fi
 done < <(git status --porcelain)
 
 for cmd in "${commands[@]}"; do
-    eval "$cmd"
+       eval "$cmd"
 done