克隆远程仓库时可选指定远程名,而不是用默认的 origin

This commit is contained in:
ZCShou 2020-07-17 10:00:37 +08:00
parent b5002cb89d
commit 232165fa3e
3 changed files with 35 additions and 7 deletions

View file

@ -23,7 +23,12 @@ namespace SourceGit.UI {
/// <summary>
/// Local name.
/// </summary>
public string LocalName { get; set; }
public string LocalName { get; set; }
/// <summary>
/// Remote name.
/// </summary>
public string RemoteName { get; set; }
/// <summary>
/// Constructor.
@ -77,12 +82,26 @@ namespace SourceGit.UI {
repoName = name.Replace(".git", "");
} else {
repoName = LocalName;
}
string rName;
if (string.IsNullOrWhiteSpace(RemoteName))
{
var from = RemoteUri.LastIndexOfAny(new char[] { '\\', '/' });
if (from <= 0) return;
var name = RemoteUri.Substring(from + 1);
rName = name.Replace(".git", "");
}
else
{
rName = RemoteName;
}
PopupManager.Lock();
var repo = await Task.Run(() => {
return Git.Repository.Clone(RemoteUri, ParentFolder, repoName, PopupManager.UpdateStatus);
return Git.Repository.Clone(RemoteUri, ParentFolder, rName, repoName, PopupManager.UpdateStatus);
});
if (repo == null) {