+ if (check_for_git()) {
+ git_fetch_us();
+ }
+ fetch_from_archive() or die;
+ printdone "fetched into ".lrref();
+}
+
+sub pull () {
+ fetch();
+ runcmd_ordryrun @git, qw(merge -m),"Merge from $suite [dgit]",
+ lrref();
+ printdone "fetched to ".lrref()." and merged into HEAD";
+}
+
+sub check_not_dirty () {
+ runcmd @git, qw(diff --quiet);
+}
+
+sub commit_quilty_patch ($) {
+ my ($vsn) = @_;
+ my $output = cmdoutput @git, qw(status --porcelain);
+ my %fixups = map {$_=>1}
+ (".pc/debian-changes-$vsn/","debian/patches/debian-changes-$vsn");
+ my @files;
+ foreach my $l (split /\n/, $output) {
+ next unless $l =~ s/^\?\? //;
+ next unless $fixups{$l};
+ push @files, $l;
+ }
+ print DEBUG "checking for quilty\n", Dumper(\@files);
+ if (@files == 2) {
+ my $m = "Commit Debian 3.0 (quilt) metadata";
+ print "$m\n";
+ runcmd_ordryrun @git, qw(add), @files;
+ runcmd_ordryrun @git, qw(commit -m), $m;
+ }
+}
+
+sub dopush () {
+ print DEBUG "actually entering push\n";
+ my $clogp = parsechangelog();
+ $package = $clogp->{Source};
+ my $dscfn = "${package}_$clogp->{Version}.dsc";
+ stat "../$dscfn" or die "$dscfn $!";
+ $dsc = parsecontrol("../$dscfn");
+ print DEBUG "format $dsc->{Format}\n";
+ if ($dsc->{Format} eq '3.0 (quilt)') {
+ print "Format \`$dsc->{Format}', urgh\n";
+ commit_quilty_patch($dsc->{Version});
+ }
+ check_not_dirty();
+ prep_ud();
+ chdir $ud or die $!;
+ print "checking that $dscfn corresponds to HEAD\n";
+ runcmd qw(dpkg-source -x --), "../../../../$dscfn";
+ my ($tree,$dir) = mktree_in_ud_from_only_subdir();
+ chdir '../../../..' or die $!;
+ runcmd @git, qw(diff --exit-code), $tree;
+#fetch from alioth
+#do fast forward check and maybe fake merge
+# if (!is_fast_fwd(mainbranch
+# runcmd @git, qw(fetch -p ), "$alioth_git/$package.git",
+# map { lref($_).":".rref($_) }
+# (uploadbranch());
+ $dsc->{$ourdscfield} = rev_parse('HEAD');
+ $dsc->save("../$dscfn.tmp") or die $!;
+ if (!$dryrun) {
+ rename "../$dscfn.tmp","../$dscfn" or die "$dscfn $!";
+ } else {
+ print "[new .dsc left in $dscfn.tmp]\n";
+ }
+ if (!$changesfile) {
+ my $pat = "../${package}_$clogp->{Version}_*.changes";
+ my @cs = glob $pat;
+ die "$pat ?" unless @cs==1;
+ ($changesfile) = @cs;
+ }
+ my $tag = debiantag($dsc->{Version});
+ if (!check_for_git()) {
+ create_remote_git_repo();
+ }
+ runcmd_ordryrun @git, qw(push),access_giturl(),"HEAD:".rrref();
+ if ($sign) {
+ my @tag_cmd = (@git, qw(tag -s -m),
+ "Release $dsc->{Version} for $suite [dgit]");
+ push @tag_cmd, qw(-u),$keyid if defined $keyid;
+ push @tag_cmd, $tag;
+ runcmd_ordryrun @tag_cmd;
+ my @debsign_cmd = @debsign;
+ push @debsign_cmd, "-k$keyid" if defined $keyid;
+ push @debsign_cmd, $changesfile;
+ runcmd_ordryrun @debsign_cmd;
+ }
+ runcmd_ordryrun @git, qw(push),access_giturl(),"refs/tags/$tag";
+ my $host = access_cfg('upload-host');
+ my @hostarg = defined($host) ? ($host,) : ();
+ runcmd_ordryrun @dput, @hostarg, $changesfile;
+ printdone "pushed and uploaded $dsc->{Version}";