mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -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="name">Local name</param>
|
||||||
/// <param name="onProgress"></param>
|
/// <param name="onProgress"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Repository Clone(string url, string folder, string name, Action<string> onProgress) {
|
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 --recurse-submodules {url} {name}", line => {
|
var errs = RunCommand(folder, $"-c credential.helper=manager clone --progress --verbose --origin {rName} --recurse-submodules {url} {lName}", line => {
|
||||||
if (line != null) onProgress?.Invoke(line);
|
if (line != null) onProgress?.Invoke(line);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ namespace SourceGit.Git {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = new DirectoryInfo(folder + "/" + name).FullName;
|
var path = new DirectoryInfo(folder + "/" + lName).FullName;
|
||||||
var repo = Preference.Instance.AddRepository(path, "");
|
var repo = Preference.Instance.AddRepository(path, "");
|
||||||
return repo;
|
return repo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:helpers="clr-namespace:SourceGit.Helpers"
|
xmlns:helpers="clr-namespace:SourceGit.Helpers"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Width="500" Height="192">
|
Width="500" Height="224">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="32"/>
|
<RowDefinition Height="32"/>
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
<RowDefinition Height="32"/>
|
<RowDefinition Height="32"/>
|
||||||
<RowDefinition Height="32"/>
|
<RowDefinition Height="32"/>
|
||||||
<RowDefinition Height="32"/>
|
<RowDefinition Height="32"/>
|
||||||
|
<RowDefinition Height="32"/>
|
||||||
<RowDefinition Height="16"/>
|
<RowDefinition Height="16"/>
|
||||||
<RowDefinition Height="32"/>
|
<RowDefinition Height="32"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
@ -70,7 +71,15 @@
|
||||||
Text="{Binding LocalName, ElementName=me, Mode=TwoWay}">
|
Text="{Binding LocalName, ElementName=me, Mode=TwoWay}">
|
||||||
</TextBox>
|
</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>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="80"/>
|
<ColumnDefinition Width="80"/>
|
||||||
|
|
|
@ -25,6 +25,11 @@ namespace SourceGit.UI {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string LocalName { get; set; }
|
public string LocalName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remote name.
|
||||||
|
/// </summary>
|
||||||
|
public string RemoteName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -79,10 +84,24 @@ namespace SourceGit.UI {
|
||||||
repoName = LocalName;
|
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();
|
PopupManager.Lock();
|
||||||
|
|
||||||
var repo = await Task.Run(() => {
|
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) {
|
if (repo == null) {
|
||||||
|
|
Loading…
Reference in a new issue