chiark / gitweb /
test suite: tagupl: Test git-debpush --upstream=
[dgit.git] / git-debpush
index 67f6555b17b5135465d65227c2eef8da2a9c8e73..ae5f20f0ea967535d0cdb04a9f6619636b829391 100755 (executable)
@@ -20,7 +20,7 @@
 set -e$DGIT_TEST_DEBPUSH_DEBUG
 set -o pipefail
 
-# PRINCIPLES OF OPERATION
+# DESIGN PRINCIPLES
 #
 # - do not invoke dgit, do anything involving any tarballs, no network
 #   access except `git push` right at the end
@@ -66,7 +66,7 @@ get_file_from_ref () {
 # ---- Parse command line
 
 getopt=$(getopt -s bash -o 'nfu:' \
-              -l 'no-push,force,branch:,remote:,distro:,quilt:,gbp,dpm,\
+              -l 'no-push,force,branch:,remote:,distro:,upstream:,quilt:,gbp,dpm,\
 baredebian,baredebian+git,baredebian+tarball' \
               -n "$us" -- "$@")
 eval "set - $getopt"
@@ -90,6 +90,7 @@ while true; do
         '--remote')       remote=$2;               shift 2; continue ;;
         '--distro')       distro=$2;               shift 2; continue ;;
         '--quilt')        quilt_mode=$2;           shift 2; continue ;;
+        '--upstream')     upstream_tag=$2;         shift 2; continue ;;
 
         '--baredebian'|'--baredebian+git')
             quilt_mode=baredebian;         shift; continue ;;
@@ -214,9 +215,26 @@ esac
 
 upstream_info=""
 if $upstream; then
-    upstream_tag=$(git deborig --just-print --version="$version" \
-                       | head -n1)
-    upstream_committish=$(git rev-parse ${upstream_tag}^{})
+    if [ "x$upstream_tag" = x ]; then
+       upstream_tag=$(
+           set +e
+           git deborig --just-print --version="$version" \
+                          | head -n1
+           ps="${PIPESTATUS[*]}"
+           set -e
+           case "$ps" in
+               "0 0"|"141 0") ;; # ok or SIGPIPE
+               *" 0")
+                   echo >&2 \
+ "$us: git-deborig failed; maybe try $us --upstream=TAG"
+                   exit 0
+                   ;;
+               *) exit 127; # presumably head will have complained
+           esac
+       )
+       if [ "x$upstream_tag" = x ]; then exit 127; fi
+    fi
+    upstream_committish=$(git rev-parse "refs/tags/${upstream_tag}"^{})
     upstream_info=" upstream-tag=$upstream_tag upstream=$upstream_committish"
 fi
 
@@ -265,5 +283,6 @@ EOF
 # ---- Do a git push
 
 if $pushing; then
-    git push "$remote" "${push_branch[@]}" "$upstream_tag" "$debian_tag"
+    # xxx when user can specify upstream_tag, must cope with spaces
+    git push "$remote" "${push_branch[@]}" $upstream_tag "$debian_tag"
 fi