summaryrefslogtreecommitdiff
path: root/bin/git-gpush
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2015-01-16 16:35:02 +0100
committerOswald Buddenhagen <oswald.buddenhagen@gmx.de>2020-04-01 17:46:35 +0000
commit13a563b8b07b5f937d8ff7a04bb75499c073c591 (patch)
treed2c8239af95d1461ba92d678d6b11ae308d264c8 /bin/git-gpush
parent5d0c6bbc68ccfe210f3b0fa8e7b6da13395e4bdc (diff)
downloadqtrepotools-13a563b8b07b5f937d8ff7a04bb75499c073c591.tar.gz
gpush/gpick: make remembered base always survive the trip through gerrit
gpick in a different clone doesn't have the gpush state file, so it wouldn't be able to recognize the end of a series which is based on other pending changes. the solution is to store the base in a custom field on gerrit. this obviously needs support in gerrit itself, which is why the feature is disabled for now. the gerrit support is tracked in QTQAINFRA-1527. Change-Id: Ia61e70412f56740019093d7aea47174cd7a7065e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'bin/git-gpush')
-rwxr-xr-xbin/git-gpush36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/git-gpush b/bin/git-gpush
index 2e14503..19936f2 100755
--- a/bin/git-gpush
+++ b/bin/git-gpush
@@ -190,6 +190,7 @@ EOM
my $from_base;
my $from;
my $commit_count = 0;
+my $addbase; # default set by process_config()
my $ref_base;
my $ref_base_ok = 1;
my $ref_to;
@@ -310,9 +311,26 @@ sub parse_arguments(@)
}
}
+use constant {
+ BASE_NO => 0,
+ BASE_MAYBE => 1,
+ BASE_YES => 2
+};
+
sub process_config()
{
load_config();
+
+ my $ab = git_config('gpush.addbase', 'maybe');
+ if ($ab eq 'maybe') {
+ $addbase = BASE_MAYBE;
+ } elsif ($ab eq 'true' || $ab eq 'yes') {
+ $addbase = BASE_YES;
+ } elsif ($ab eq 'false' || $ab eq 'no') {
+ $addbase = BASE_NO;
+ } else {
+ fail("Unrecognized value for gpush.addbase.\n");
+ }
}
sub lookup_alias($)
@@ -1150,7 +1168,25 @@ sub push_changes($)
my $tpc = $$group{topic};
my ($rvrs, $ccs) = ($$group{add_rvrs} // [], $$group{add_ccs} // []);
+ my $base = $$group{base};
+ if ($addbase == BASE_YES) {
+ print "Configuration mandates sending base.\n" if ($debug);
+ } elsif ($addbase == BASE_MAYBE) {
+ if ($commit_by_id{$base}) {
+ # Series which are pushed on top of other pending Changes have their
+ # base stored in an extra field on Gerrit, as otherwise gpick could
+ # not reliably determine it.
+ print "Sending base, as it is not in the upstream branch.\n" if ($debug);
+ } else {
+ $base = undef;
+ }
+ } else {
+ print "Configuration forbids sending base.\n" if ($debug);
+ $base = undef;
+ }
+
my @push_options;
+ push @push_options, "gpush-base=$base" if (defined($base));
push @push_options, "topic=$tpc" if (defined($tpc));
push @push_options, map { "r=$_" } @$rvrs;
push @push_options, map { "cc=$_" } @$ccs;