mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
fix: changing the repository URL only changes the fetch URL if push URL using a different URL (#553)
This commit is contained in:
parent
93706449be
commit
c2b17ef9d0
2 changed files with 15 additions and 3 deletions
|
@ -32,9 +32,17 @@
|
||||||
return Exec();
|
return Exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetURL(string name, string url)
|
public string GetURL(string name, bool isPush)
|
||||||
{
|
{
|
||||||
Args = $"remote set-url {name} {url}";
|
Args = "remote get-url" + (isPush ? " --push " : " ") + name;
|
||||||
|
|
||||||
|
var rs = ReadToEnd();
|
||||||
|
return rs.IsSuccess ? rs.StdOut.Trim() : string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetURL(string name, string url, bool isPush)
|
||||||
|
{
|
||||||
|
Args = "remote set-url" + (isPush ? " --push " : " ") + $"{name} {url}";
|
||||||
return Exec();
|
return Exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,11 +118,15 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
if (_remote.URL != _url)
|
if (_remote.URL != _url)
|
||||||
{
|
{
|
||||||
var succ = new Commands.Remote(_repo.FullPath).SetURL(_name, _url);
|
var succ = new Commands.Remote(_repo.FullPath).SetURL(_name, _url, false);
|
||||||
if (succ)
|
if (succ)
|
||||||
_remote.URL = _url;
|
_remote.URL = _url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pushURL = new Commands.Remote(_repo.FullPath).GetURL(_name, true);
|
||||||
|
if (pushURL != _url)
|
||||||
|
new Commands.Remote(_repo.FullPath).SetURL(_name, _url, true);
|
||||||
|
|
||||||
SetProgressDescription("Post processing ...");
|
SetProgressDescription("Post processing ...");
|
||||||
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null);
|
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue