Commit 3bd052b6 authored by Johan Ouwerkerk's avatar Johan Ouwerkerk
Browse files

Make sure to remove old pushInsteadOf mapping if git-desired-protocol changes.

parent 220bdb6c
Pipeline #20348 canceled with stage
......@@ -855,9 +855,11 @@ sub verifyGitConfig
my $protocol = $contextOptions->getOption('git-desired-protocol') || 'git';
my $pushUrlPrefix = '';
my $otherPushUrlPrefix = '';
if ($protocol eq 'git' || $protocol eq 'https') {
$pushUrlPrefix = $protocol eq 'git' ? 'git@invent.kde.org:' : 'https://invent.kde.org/';
$pushUrlPrefix = $protocol eq 'git' ? 'ssh://git@invent.kde.org/' : 'https://invent.kde.org/';
$otherPushUrlPrefix = $protocol eq 'git' ? 'https://invent.kde.org/' : 'ssh://git@invent.kde.org/';
}
else {
error(" b[y[*] Invalid b[git-desired-protocol] $protocol");
......@@ -889,7 +891,7 @@ sub verifyGitConfig
# If we make it here, I'm just going to assume git works from here on out
# on this simple task.
if ($configOutput !~ /^kde:\s*$/) {
whisper ("\tAdding git download kde: alias");
whisper ("\tAdding git download kde: alias (fetch: https://invent.kde.org/)");
my $result = safe_system(
qw(git config --global --add url.https://invent.kde.org/.insteadOf kde:)
) >> 8;
......@@ -900,7 +902,7 @@ sub verifyGitConfig
qx"git config --global --get url.$pushUrlPrefix.pushInsteadOf kde:";
if ($configOutput !~ /^kde:\s*$/) {
whisper ("\tAdding git upload kde: alias");
whisper ("\tAdding git upload kde: alias (push: $pushUrlPrefix)");
my $result = safe_system("git config --global --add url.$pushUrlPrefix.pushInsteadOf kde:") >> 8;
return 0 if $result != 0;
}
......@@ -910,7 +912,7 @@ sub verifyGitConfig
qx'git config --global --get url.git://anongit.kde.org/.insteadOf kde:';
if ($configOutput =~ /^kde:\s*$/) {
whisper ("\tRemoving outdated kde: alias");
whisper ("\tRemoving outdated kde: alias (fetch: git://anongit.kde.org/)");
my $result = safe_system(
qw(git config --global --unset-all url.git://anongit.kde.org/.insteadOf kde:)
) >> 8;
......@@ -921,7 +923,7 @@ sub verifyGitConfig
qx'git config --global --get url.https://anongit.kde.org/.insteadOf kde:';
if ($configOutput =~ /^kde:\s*$/) {
whisper ("\tRemoving outdated kde: alias");
whisper ("\tRemoving outdated kde: alias (fetch: https://anongit.kde.org/)");
my $result = safe_system(
qw(git config --global --unset-all url.https://anongit.kde.org/.insteadOf kde:)
) >> 8;
......@@ -932,13 +934,24 @@ sub verifyGitConfig
qx'git config --global --get url.git@git.kde.org:.pushInsteadOf kde:';
if ($configOutput =~ /^kde:\s*$/) {
whisper ("\tRemoving outdated kde: alias");
whisper ("\tRemoving outdated kde: alias (push: git\@git.kde.org)");
my $result = safe_system(
qw(git config --global --unset-all url.git@git.kde.org:.pushInsteadOf kde:)
) >> 8;
return 0 if $result != 0;
}
# remove outdated alias if git-desired-protocol gets flipped
$configOutput =
qx"git config --global --get url.$otherPushUrlPrefix.pushInsteadOf kde:";
if ($configOutput =~ /^kde:\s*$/) {
whisper ("\tRemoving outdated kde: alias (push: $otherPushUrlPrefix)");
my $result = safe_system("git config --global --unset-all url.$otherPushUrlPrefix.pushInsteadOf kde:") >> 8;
return 0 if $result != 0;
}
return 1;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment