chiark / gitweb /
New import: Tidy up output from gbp pq
[dgit.git] / dgit
diff --git a/dgit b/dgit
index b4b6d9cd4ea79467a9d86cb9b3df7e5d5f997af8..def2c349af4668589df46d30c7ba09d61b7a8d72 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -77,6 +77,9 @@ our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
 
 our $suite_re = '[-+.0-9a-z]+';
 our $cleanmode_re = 'dpkg-source(?:-d)?|git|git-ff|check|none';
+our $orig_f_comp_re = 'orig(?:-[-0-9a-z]+)?';
+our $orig_f_sig_re = '\\.(?:asc|gpg|pgp)';
+our $orig_f_tail_re = "$orig_f_comp_re\\.tar(?:\\.\\w+)?(?:$orig_f_sig_re)?";
 
 our $git_authline_re = '^([^<>]+) \<(\S+)\> (\d+ [-+]\d+)$';
 our $splitbraincache = 'dgit-intern/quilt-cache';
@@ -1434,14 +1437,14 @@ sub is_orig_file_in_dsc ($$) {
     return 0 if @$dsc_files_info <= 1;
     # One file means no origs, and the filename doesn't have a "what
     # part of dsc" component.  (Consider versions ending `.orig'.)
-    return 0 unless $f =~ m/\.orig(?:-\w+)?\.tar(?:\.\w+)?$/;
+    return 0 unless $f =~ m/\.$orig_f_tail_re$/o;
     return 1;
 }
 
 sub is_orig_file_of_vsn ($$) {
     my ($f, $upstreamvsn) = @_;
     my $base = srcfn $upstreamvsn, '';
-    return 0 unless $f =~ m/^\Q$base\E\.orig(?:-\w+)?\.tar(?:\.\w+)?$/;
+    return 0 unless $f =~ m/^\Q$base\E\.$orig_f_tail_re$/;
     return 1;
 }
 
@@ -1591,6 +1594,7 @@ sub generate_commits_from_dsc () {
        printdebug "import considering $f ";
        (printdebug "only one dfi\n"), next if @dfi == 1;
        (printdebug "not tar\n"), next unless $f =~ m/\.tar(\.\w+)?$/;
+       (printdebug "signature\n"), next if $f =~ m/$orig_f_sig_re$/o;
        my $compr_ext = $1;
 
        my ($orig_f_part) =
@@ -1707,8 +1711,11 @@ sub generate_commits_from_dsc () {
     my $clogp;
     my $r1clogp;
 
+    printdebug "import clog search...\n";
+
     for (;;) {
        my $stanzatext = do { local $/=""; <CLOGS>; };
+       printdebug "import clogp ".Dumper($stanzatext) if $debuglevel>1;
        last if !defined $stanzatext;
 
        my $desc = "package changelog, entry no.$.";
@@ -1716,6 +1723,8 @@ sub generate_commits_from_dsc () {
        my $thisstanza = parsecontrolfh $stanzafh, $desc, 1;
        $clogp //= $thisstanza;
 
+       printdebug "import clog $thisstanza->{version} $desc...\n";
+
        last if !$any_orig; # we don't need $r1clogp
 
        # We look for the first (most recent) changelog entry whose
@@ -1740,8 +1749,12 @@ sub generate_commits_from_dsc () {
        # versions were created in a non-monotic order rather than
        # that the changelog entries have been misordered.
 
+       printdebug "import clog $thisstanza->{version} vs $upstreamv...\n";
+
        last if version_compare($thisstanza->{version}, $upstreamv) < 0;
        $r1clogp = $thisstanza;
+
+       printdebug "import clog $r1clogp->{version} becomes r1\n";
     }
     die $! if CLOGS->error;
     close CLOGS or $?==(SIGPIPE<<8) or failedcmd @clogcmd;
@@ -1758,7 +1771,12 @@ sub generate_commits_from_dsc () {
        # Strictly, r1authline might now be wrong if it's going to be
        # unused because !$any_orig.  Whatever.
 
+       printdebug "import tartrees authline   $authline\n";
+       printdebug "import tartrees r1authline $r1authline\n";
+
        foreach my $tt (@tartrees) {
+           printdebug "import tartree $tt->{F} $tt->{Tree}\n";
+
            $tt->{Commit} = make_commit_text($tt->{Orig} ? <<END_O : <<END_T);
 tree $tt->{Tree}
 author $r1authline
@@ -1779,6 +1797,8 @@ END_T
        }
     }
 
+    printdebug "import main commit\n";
+
     open C, ">../commit.tmp" or die $!;
     print C <<END or die $!;
 tree $tree
@@ -1799,6 +1819,8 @@ END
     my $rawimport_hash = make_commit qw(../commit.tmp);
 
     if (madformat $dsc->{format}) {
+       printdebug "import apply patches...\n";
+
        # regularise the state of the working tree so that
        # the checkout of $rawimport_hash works nicely.
        my $dappliedcommit = make_commit_text(<<END);
@@ -1808,10 +1830,28 @@ committer $authline
 
 [dgit dummy commit]
 END
-       runcmd @git, qw(checkout -b dapplied), $dappliedcommit;
+       runcmd @git, qw(checkout -q -b dapplied), $dappliedcommit;
+
+       runcmd @git, qw(checkout -q -b unpa), $rawimport_hash;
+
+       # We need the answers to be reproducible
+       my @authline = clogp_authline($clogp);
+       local $ENV{GIT_COMMITTER_NAME} =  $authline[0];
+       local $ENV{GIT_COMMITTER_EMAIL} = $authline[1];
+       local $ENV{GIT_COMMITTER_DATE} =  $authline[2];
+       local $ENV{GIT_AUTHOR_NAME} =  $authline[0];
+       local $ENV{GIT_AUTHOR_EMAIL} = $authline[1];
+       local $ENV{GIT_AUTHOR_DATE} =  $authline[2];
+
+       eval {
+           runcmd shell_cmd 'exec >/dev/null 2>../../gbp-pq-output',
+               @gbp, qw(pq import);
+       };
+       if ($@) {
+           { local $@; eval { runcmd qw(cat ../../gbp-pq-output); }; }
+           die $@;
+       }
 
-       runcmd @git, qw(checkout -b unpa), $rawimport_hash;
-       runcmd shell_cmd 'exec >/dev/null', @gbp, qw(pq import);
        my $gapplied = git_rev_parse('HEAD');
        my $gappliedtree = cmdoutput @git, qw(rev-parse HEAD:);
        $gappliedtree eq $dappliedtree or
@@ -2383,7 +2423,7 @@ END
     } else {
        $hash = $mergeinputs[0]{Commit};
     }
-    progress "fetch hash=$hash\n";
+    printdebug "fetch hash=$hash\n";
 
     my $chkff = sub {
        my ($lasth, $what) = @_;
@@ -3657,7 +3697,10 @@ sub quiltify_splitbrain ($$$$$$) {
     local $ENV{GIT_COMMITTER_NAME} =  $authline[0];
     local $ENV{GIT_COMMITTER_EMAIL} = $authline[1];
     local $ENV{GIT_COMMITTER_DATE} =  $authline[2];
-       
+    local $ENV{GIT_AUTHOR_NAME} =  $authline[0];
+    local $ENV{GIT_AUTHOR_EMAIL} = $authline[1];
+    local $ENV{GIT_AUTHOR_DATE} =  $authline[2];
+
     if ($quilt_mode =~ m/gbp|unapplied/ &&
        ($diffbits->{H2O} & 01)) {
        my $msg =
@@ -3710,7 +3753,7 @@ The Debian packaging git branch contains these updates to the upstream
 .gitignore file(s).  This patch is autogenerated, to provide these
 updates to users of the official Debian archive view of the package.
 
-[dgit version $our_version]
+[dgit ($our_version) update-gitignore]
 ---
 END
         close GIPATCH or die "$gipatch: $!";