mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
克隆远程仓库时可选指定远程名,而不是用默认的 origin
This commit is contained in:
parent
b5002cb89d
commit
232165fa3e
3 changed files with 35 additions and 7 deletions
|
@ -391,8 +391,8 @@ namespace SourceGit.Git {
|
|||
/// <param name="name">Local name</param>
|
||||
/// <param name="onProgress"></param>
|
||||
/// <returns></returns>
|
||||
public static Repository Clone(string url, string folder, string name, Action<string> onProgress) {
|
||||
var errs = RunCommand(folder, $"-c credential.helper=manager clone --progress --verbose --recurse-submodules {url} {name}", line => {
|
||||
public static Repository Clone(string url, string folder, string rName, string lName, Action<string> onProgress) {
|
||||
var errs = RunCommand(folder, $"-c credential.helper=manager clone --progress --verbose --origin {rName} --recurse-submodules {url} {lName}", line => {
|
||||
if (line != null) onProgress?.Invoke(line);
|
||||
}, true);
|
||||
|
||||
|
@ -401,7 +401,7 @@ namespace SourceGit.Git {
|
|||
return null;
|
||||
}
|
||||
|
||||
var path = new DirectoryInfo(folder + "/" + name).FullName;
|
||||
var path = new DirectoryInfo(folder + "/" + lName).FullName;
|
||||
var repo = Preference.Instance.AddRepository(path, "");
|
||||
return repo;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:helpers="clr-namespace:SourceGit.Helpers"
|
||||
mc:Ignorable="d"
|
||||
Width="500" Height="192">
|
||||
Width="500" Height="224">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32"/>
|
||||
|
@ -14,6 +14,7 @@
|
|||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="16"/>
|
||||
<RowDefinition Height="32"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
@ -70,7 +71,15 @@
|
|||
Text="{Binding LocalName, ElementName=me, Mode=TwoWay}">
|
||||
</TextBox>
|
||||
|
||||
<Grid Grid.Row="6" Grid.ColumnSpan="2">
|
||||
<Label Grid.Row="5" Grid.Column="0" HorizontalAlignment="Right" Content="Remote Name :"/>
|
||||
<TextBox Grid.Row="5" Grid.Column="1"
|
||||
VerticalContentAlignment="Center"
|
||||
Height="24"
|
||||
helpers:TextBoxHelper.Placeholder="Remote name. Optional."
|
||||
Text="{Binding RemoteName, ElementName=me, Mode=TwoWay}">
|
||||
</TextBox>
|
||||
|
||||
<Grid Grid.Row="7" Grid.ColumnSpan="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="80"/>
|
||||
|
|
|
@ -25,6 +25,11 @@ namespace SourceGit.UI {
|
|||
/// </summary>
|
||||
public string LocalName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Remote name.
|
||||
/// </summary>
|
||||
public string RemoteName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
|
@ -79,10 +84,24 @@ namespace SourceGit.UI {
|
|||
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) {
|
||||
|
|
Loading…
Reference in a new issue