chiark / gitweb /
git-debpush: cope with spaces in user-supplied upstream tag
[dgit.git] / git-debpush
index 6c41908633f10c3fca193e07ea872eacce515d89..1902fa93f7ff0cab98ba8661efcb9ce0f4435585 100755 (executable)
@@ -220,11 +220,20 @@ if ! [ "x$last_debian_tag" = "x" ] && ! [ "x$last_archive_tag" = "x" ]; then
     fi
 fi
 
-# TODO additional checks we might do:
-#
-# - are we uploading to a different suite from the last tag
-#   (e.g. unstable after experimental)?  user should pass option to
-#   confirm
+if ! [ "x$last_debian_tag" = "x" ]; then
+    temp=$(mktemp -d)
+    trap cleanup EXIT
+    mkdir "$temp/debian"
+    git cat-file blob "$last_debian_tag":debian/changelog >"$temp/debian/changelog"
+    prev_target=$(cd $temp; dpkg-parsechangelog -SDistribution)
+    rm -rf "$temp"
+    trap - EXIT
+
+    if ! [ "$prev_target" = "$target" ] && ! [ "$target" = "UNRELEASED" ]; then
+        fail_check \
+"last upload targeted $prev_target, now targeting $target; might be a mistake?"
+    fi
+fi
 
 if ! $force && $failed_check; then
     fail "some checks failed; you can override with --force"
@@ -314,6 +323,9 @@ EOF
 # ---- Do a git push
 
 if $pushing; then
-    # xxx when user can specify upstream_tag, must cope with spaces
-    git push "$remote" "${push_branch[@]}" $upstream_tag "$debian_tag"
+    if [ "x$upstream_tag" = "x" ]; then
+        git push "$remote" "${push_branch[@]}" "$debian_tag"
+    else
+        git push "$remote" "${push_branch[@]}" "$debian_tag" "$upstream_tag"
+    fi
 fi