summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@gmx.de>2023-02-03 16:31:30 +0100
committerOswald Buddenhagen <oswald.buddenhagen@gmx.de>2023-02-20 16:18:21 +0000
commit5ff4c5c41859006e020a824f8c87fb1bf9e0f3ca (patch)
tree7129ac3a223fe731b1bb07729fd96643f5a9cdc9
parent00464833e2fae20eaa9905a8a5db3d5542a2571a (diff)
downloadqtrepotools-5ff4c5c41859006e020a824f8c87fb1bf9e0f3ca.tar.gz
gpush: heed git's ssh config
Fixes: QTQAINFRA-5398 Change-Id: Ia5a5ec3b0cf005ab4271e2418bd4a45743fa9f9c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rwxr-xr-xbin/git-gpush4
-rw-r--r--bin/git_gpush.pm14
2 files changed, 14 insertions, 4 deletions
diff --git a/bin/git-gpush b/bin/git-gpush
index 77dc221..2d47df0 100755
--- a/bin/git-gpush
+++ b/bin/git-gpush
@@ -1853,7 +1853,7 @@ sub update_unpushed($)
my ($rvrs, $ccs) = ($$group{add_rvrs} // [], $$group{add_ccs} // []);
if (@$rvrs) {
run_process(FWD_OUTPUT | DRY_RUN,
- 'ssh', @gerrit_ssh, 'gerrit', 'set-reviewers',
+ @gerrit_ssh, 'gerrit', 'set-reviewers',
(map { ('-a', $_) } @$rvrs), '--', (map { $$_{key} } @$invite_list));
}
if (@$ccs) {
@@ -1871,7 +1871,7 @@ sub update_unpushed($)
if (!$quiet && !$printed);
$printed = 1;
run_process(FWD_OUTPUT | DRY_RUN,
- 'ssh', @gerrit_ssh, 'gerrit', 'set-topic',
+ @gerrit_ssh, 'gerrit', 'set-topic',
'-t', $$group{topic}, map { $$_{key} } @$topic_list);
}
}
diff --git a/bin/git_gpush.pm b/bin/git_gpush.pm
index 455ebf0..351f44d 100644
--- a/bin/git_gpush.pm
+++ b/bin/git_gpush.pm
@@ -2167,7 +2167,7 @@ sub _update_target_branches($)
# URL for pushing/fetching from the Gerrit instance.
our $gerrit_url;
-# SSH arguments for connecting the Gerrit instance.
+# SSH command with arguments for connecting the Gerrit instance.
our @gerrit_ssh;
# Target repository name on the Gerrit instance.
our $gerrit_project;
@@ -2192,6 +2192,16 @@ sub set_gerrit_config($)
} else {
fail("Remote '$rmt' does not use a supported protocol.\n")
}
+ if (@gerrit_ssh) {
+ # Precedence according to git/connect.c:fill_ssh_args()
+ my $gssh = $ENV{GIT_SSH_COMMAND} // git_config('core.sshcommand');
+ if (defined($gssh)) {
+ # Should use shell rules here, but that seems like overkill.
+ unshift @gerrit_ssh, split(/ /, $gssh);
+ } else {
+ unshift @gerrit_ssh, $ENV{GIT_SSH} // 'ssh';
+ }
+ }
}
sub query_gerrit_only($;$)
@@ -2199,7 +2209,7 @@ sub query_gerrit_only($;$)
my ($ids, $extra) = @_;
my @ginfos;
- my $info = open_cmd_pipe(0, 'ssh', @gerrit_ssh, 'gerrit', 'query', '--format', 'JSON',
+ my $info = open_cmd_pipe(0, @gerrit_ssh, 'gerrit', 'query', '--format', 'JSON',
'--no-limit', '--patch-sets', $extra ? @$extra : (),
"project:$gerrit_project", '\\('.join(' OR ', @$ids).'\\)');
while (read_process($info)) {