From: Graham Knop Date: Mon, 25 Apr 2022 13:06:04 +0000 (+0200) Subject: when refreshing upstream, use push URL X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=p5sagit%2FDistar.git when refreshing upstream, use push URL Part of the release process involves pushing to the git remote, so try to validate that early. We can't do an actual push early, to verify the permissions, but we can at least verify that the push URL works. This can be a problem when using different URLs for pull vs push, like https for pull and ssh for push. If you are on a restricted network, one may fail while the other would work. --- diff --git a/lib/Distar/helpers/preflight b/lib/Distar/helpers/preflight index 9e87cbb..ad92b09 100755 --- a/lib/Distar/helpers/preflight +++ b/lib/Distar/helpers/preflight @@ -16,11 +16,6 @@ my $version = shift or die "version required!"; my $make = $Config{make}; my $null = File::Spec->devnull; -system("git fetch"); -if (system("git rev-parse --quiet --verify v$version >$null") == 0) { - die "Tag v$version already exists!"; -} - chomp(my $head = `git symbolic-ref -q HEAD`); (my $current_branch = $head) =~ s{^refs/heads/}{}; $head eq "refs/heads/$branch" @@ -28,6 +23,19 @@ $head eq "refs/heads/$branch" chomp(my $upstream = `git for-each-ref --format="%(upstream)" $head`); length $upstream or die "No upstream branch configured for $branch!\n"; + +my (undef, undef, $remote) = split qr{/}, $upstream; + +my $push_url = `git remote get-url --push $remote`; +chomp $push_url; + +system(qq[git -c remote.$remote.url="$push_url" fetch]) == 0 + or exit 1; + +if (system("git rev-parse --quiet --verify v$version >$null") == 0) { + die "Tag v$version already exists!"; +} + my $base_rev = `git merge-base $upstream $head`; my $upstream_rev = `git rev-parse --verify $upstream`; $upstream_rev eq $base_rev