chiark / gitweb /
Better handling of packages pushed using dgit and stuck in NEW. (And, use of `--new...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 11 Sep 2013 22:34:56 +0000 (23:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 11 Sep 2013 22:34:59 +0000 (23:34 +0100)
Specifically
 * get_archive_dsc leaves its answer in $dsc, not the return value
 * fetch_from_archive tolerates get_archive_dsc saying "no", and
   then uses the git ref, with a warning message

debian/changelog
dgit

index 191ea084c0ed808ca585854448c3e7e7923e5c9e..507d2c1396852619734f00ff740bf14c99fe50e0 100644 (file)
@@ -2,6 +2,8 @@ dgit (0.15) unstable; urgency=low
 
   * Implement `dgit help' as well as `--help'.  Closes: #721661.
   * Provide `dgit version' and `--version'.  Closes: #721654.
+  * Better handling of packages pushed using dgit and stuck in NEW.
+    (And, use of `--new' is not needed with fetch.)  Closes: #722199.
 
  --
 
diff --git a/dgit b/dgit
index 562cef08f913eab9dbf2910dccf6da94c00372a7..f77d349b400c344adf13945c6f5e9fd6db3e3b62 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -452,9 +452,9 @@ sub get_archive_dsc () {
        print DEBUG Dumper($dsc) if $debug>1;
        my $fmt = getfield $dsc, 'Format';
        fail "unsupported source format $fmt, sorry" unless $format_ok{$fmt};
-       return $dsc;
+       return;
     }
-    return undef;
+    $dsc = undef;
 }
 
 sub check_for_git () {
@@ -688,17 +688,22 @@ sub git_fetch_us () {
 sub fetch_from_archive () {
     # ensures that lrref() is what is actually in the archive,
     #  one way or another
-    get_archive_dsc() or return 0;
-    foreach my $field (@ourdscfield) {
-       $dsc_hash = $dsc->{$field};
-       last if defined $dsc_hash;
-    }
-    if (defined $dsc_hash) {
-       $dsc_hash =~ m/\w+/ or fail "invalid hash in .dsc \`$dsc_hash'";
-       $dsc_hash = $&;
-       print "last upload to archive specified git hash\n";
+    get_archive_dsc();
+
+    if ($dsc) {
+       foreach my $field (@ourdscfield) {
+           $dsc_hash = $dsc->{$field};
+           last if defined $dsc_hash;
+       }
+       if (defined $dsc_hash) {
+           $dsc_hash =~ m/\w+/ or fail "invalid hash in .dsc \`$dsc_hash'";
+           $dsc_hash = $&;
+           print "last upload to archive specified git hash\n";
+       } else {
+           print "last upload to archive has NO git hash\n";
+       }
     } else {
-       print "last upload to archive has NO git hash\n";
+       print "no version available from the archive\n";
     }
 
     my $lrref_fn = ".git/".lrref();
@@ -734,8 +739,20 @@ END
            fail "archive's .dsc refers to ".$dsc_hash.
                " but this is an ancestor of ".$lastpush_hash;
        }
-    } else {
+    } elsif ($dsc) {
        $hash = generate_commit_from_dsc();
+    } elsif ($lastpush_hash) {
+       # only in git, not in the archive yet
+       $hash = $lastpush_hash;
+       print STDERR <<END or die $!;
+
+Package not found in the archive, but has allegedly been
+pushed/uploaded using dgit.
+$later_warning_msg
+END
+    } else {
+       print DEBUG "nothing found!\n";
+       return 0;
     }
     print DEBUG "current hash=$hash\n";
     if ($lastpush_hash) {