mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
feature<Clone>: support additional parameters to clone remote repository
This commit is contained in:
parent
14f303038e
commit
91f3f1263a
5 changed files with 30 additions and 11 deletions
|
@ -412,18 +412,22 @@ namespace SourceGit.Git {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="url">Remote repository URL</param>
|
/// <param name="url">Remote repository URL</param>
|
||||||
/// <param name="folder">Folder to clone into</param>
|
/// <param name="folder">Folder to clone into</param>
|
||||||
/// <param name="name">Local name</param>
|
/// <param name="rName">Remote name</param>
|
||||||
|
/// <param name="lName">Local name</param>
|
||||||
|
/// <param name="extra">Additional parameters</param>
|
||||||
/// <param name="onProgress"></param>
|
/// <param name="onProgress"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool Clone(string url, string folder, string rName, string lName, Action<string> onProgress) {
|
public static bool Clone(string url, string folder, string rName, string lName, string extra, Action<string> onProgress) {
|
||||||
string RemoteName;
|
string RemoteName;
|
||||||
if (rName != null) {
|
if (rName != null) {
|
||||||
RemoteName = $" --origin {rName}";
|
RemoteName = $" --origin {rName}";
|
||||||
} else {
|
} else {
|
||||||
RemoteName = null;
|
RemoteName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
var errs = RunCommand(folder, $"-c credential.helper=manager clone --progress --verbose {RemoteName} --recurse-submodules {url} {lName}", line => {
|
if (extra == null) extra = "";
|
||||||
|
|
||||||
|
var errs = RunCommand(folder, $"-c credential.helper=manager clone --progress --verbose {RemoteName} --recurse-submodules {extra} {url} {lName}", line => {
|
||||||
if (line != null) onProgress?.Invoke(line);
|
if (line != null) onProgress?.Invoke(line);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@
|
||||||
<sys:String x:Key="Text.Clone.LocalName.Placeholder">Repository name. Optional.</sys:String>
|
<sys:String x:Key="Text.Clone.LocalName.Placeholder">Repository name. Optional.</sys:String>
|
||||||
<sys:String x:Key="Text.Clone.RemoteName">Remote Name :</sys:String>
|
<sys:String x:Key="Text.Clone.RemoteName">Remote Name :</sys:String>
|
||||||
<sys:String x:Key="Text.Clone.RemoteName.Placeholder">Remote name. Optional.</sys:String>
|
<sys:String x:Key="Text.Clone.RemoteName.Placeholder">Remote name. Optional.</sys:String>
|
||||||
|
<sys:String x:Key="Text.Clone.AdditionalParam">Extra Parameters :</sys:String>
|
||||||
|
<sys:String x:Key="Text.Clone.AdditionalParam.Placeholder">Additional arguments to clone repository. Optional.</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.CommitViewer.Info">INFORMATION</sys:String>
|
<sys:String x:Key="Text.CommitViewer.Info">INFORMATION</sys:String>
|
||||||
<sys:String x:Key="Text.CommitViewer.Info.Author">AUTHOR</sys:String>
|
<sys:String x:Key="Text.CommitViewer.Info.Author">AUTHOR</sys:String>
|
||||||
|
|
|
@ -65,6 +65,8 @@
|
||||||
<sys:String x:Key="Text.Clone.LocalName.Placeholder">本地仓库目录的名字,选填</sys:String>
|
<sys:String x:Key="Text.Clone.LocalName.Placeholder">本地仓库目录的名字,选填</sys:String>
|
||||||
<sys:String x:Key="Text.Clone.RemoteName">远程名 :</sys:String>
|
<sys:String x:Key="Text.Clone.RemoteName">远程名 :</sys:String>
|
||||||
<sys:String x:Key="Text.Clone.RemoteName.Placeholder">远程的名字,选填</sys:String>
|
<sys:String x:Key="Text.Clone.RemoteName.Placeholder">远程的名字,选填</sys:String>
|
||||||
|
<sys:String x:Key="Text.Clone.AdditionalParam">额外参数 :</sys:String>
|
||||||
|
<sys:String x:Key="Text.Clone.AdditionalParam.Placeholder">其他克隆参数,选填</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.CommitViewer.Info">基本信息</sys:String>
|
<sys:String x:Key="Text.CommitViewer.Info">基本信息</sys:String>
|
||||||
<sys:String x:Key="Text.CommitViewer.Info.Author">修改者</sys:String>
|
<sys:String x:Key="Text.CommitViewer.Info.Author">修改者</sys:String>
|
||||||
|
|
|
@ -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="224">
|
Width="500" Height="256">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="32"/>
|
<RowDefinition Height="32"/>
|
||||||
|
@ -15,6 +15,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>
|
||||||
|
@ -68,18 +69,23 @@
|
||||||
VerticalContentAlignment="Center"
|
VerticalContentAlignment="Center"
|
||||||
Height="24"
|
Height="24"
|
||||||
helpers:TextBoxHelper.Placeholder="{StaticResource Text.Clone.LocalName.Placeholder}"
|
helpers:TextBoxHelper.Placeholder="{StaticResource Text.Clone.LocalName.Placeholder}"
|
||||||
Text="{Binding LocalName, ElementName=me, Mode=TwoWay}">
|
Text="{Binding LocalName, ElementName=me, Mode=TwoWay}"/>
|
||||||
</TextBox>
|
|
||||||
|
|
||||||
<Label Grid.Row="5" Grid.Column="0" HorizontalAlignment="Right" Content="{StaticResource Text.Clone.RemoteName}"/>
|
<Label Grid.Row="5" Grid.Column="0" HorizontalAlignment="Right" Content="{StaticResource Text.Clone.RemoteName}"/>
|
||||||
<TextBox Grid.Row="5" Grid.Column="1"
|
<TextBox Grid.Row="5" Grid.Column="1"
|
||||||
VerticalContentAlignment="Center"
|
VerticalContentAlignment="Center"
|
||||||
Height="24"
|
Height="24"
|
||||||
helpers:TextBoxHelper.Placeholder="{StaticResource Text.Clone.RemoteName.Placeholder}"
|
helpers:TextBoxHelper.Placeholder="{StaticResource Text.Clone.RemoteName.Placeholder}"
|
||||||
Text="{Binding RemoteName, ElementName=me, Mode=TwoWay}">
|
Text="{Binding RemoteName, ElementName=me, Mode=TwoWay}"/>
|
||||||
</TextBox>
|
|
||||||
|
|
||||||
<Grid Grid.Row="7" Grid.ColumnSpan="2">
|
<Label Grid.Row="6" Grid.Column="0" HorizontalAlignment="Right" Content="{StaticResource Text.Clone.AdditionalParam}"/>
|
||||||
|
<TextBox Grid.Row="6" Grid.Column="1"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Height="24"
|
||||||
|
helpers:TextBoxHelper.Placeholder="{StaticResource Text.Clone.AdditionalParam.Placeholder}"
|
||||||
|
Text="{Binding AdditionalParam, ElementName=me, Mode=TwoWay}"/>
|
||||||
|
|
||||||
|
<Grid Grid.Row="8" Grid.ColumnSpan="2">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="80"/>
|
<ColumnDefinition Width="80"/>
|
||||||
|
|
|
@ -33,6 +33,11 @@ namespace SourceGit.UI {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string RemoteName { get; set; }
|
public string RemoteName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Additional parameters
|
||||||
|
/// </summary>
|
||||||
|
public string AdditionalParam { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -87,7 +92,7 @@ namespace SourceGit.UI {
|
||||||
popup.Lock();
|
popup.Lock();
|
||||||
|
|
||||||
var succ = await Task.Run(() => {
|
var succ = await Task.Run(() => {
|
||||||
return Git.Repository.Clone(RemoteUri, ParentFolder, rName, repoName, popup.UpdateStatus);
|
return Git.Repository.Clone(RemoteUri, ParentFolder, rName, repoName, AdditionalParam, popup.UpdateStatus);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (succ) {
|
if (succ) {
|
||||||
|
|
Loading…
Reference in a new issue