mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
feat(*): 为 Pull、Fetch、Push 增加 --recurse-submodules 选项参数
This commit is contained in:
parent
d29e5def4b
commit
ceff6ef102
8 changed files with 84 additions and 26 deletions
|
@ -57,7 +57,7 @@ namespace SourceGit.Git {
|
|||
if (errs != null) {
|
||||
App.RaiseError(errs);
|
||||
} else {
|
||||
repo.Fetch(new Remote() { Name = name }, true, null);
|
||||
repo.Fetch(new Remote() { Name = name }, "--recurse-submodules=on-demand", true, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -448,12 +448,13 @@ namespace SourceGit.Git {
|
|||
/// Fetch remote changes
|
||||
/// </summary>
|
||||
/// <param name="remote"></param>
|
||||
/// <param name="submod">submod</param>
|
||||
/// <param name="prune"></param>
|
||||
/// <param name="onProgress"></param>
|
||||
public void Fetch(Remote remote, bool prune, Action<string> onProgress) {
|
||||
public void Fetch(Remote remote, string submod, bool prune, Action<string> onProgress) {
|
||||
isWatcherDisabled = true;
|
||||
|
||||
var args = "-c credential.helper=manager fetch --progress --verbose ";
|
||||
var args = $"-c credential.helper=manager fetch --progress --verbose {submod} ";
|
||||
|
||||
if (prune) args += "--prune ";
|
||||
|
||||
|
@ -475,14 +476,15 @@ namespace SourceGit.Git {
|
|||
/// </summary>
|
||||
/// <param name="remote">remote</param>
|
||||
/// <param name="branch">branch</param>
|
||||
/// <param name="submod">submod</param>
|
||||
/// <param name="onProgress">Progress message handler.</param>
|
||||
/// <param name="rebase">Use rebase instead of merge.</param>
|
||||
/// <param name="autostash">Auto stash local changes.</param>
|
||||
/// <param name="onProgress">Progress message handler.</param>
|
||||
public void Pull(string remote, string branch, Action<string> onProgress, bool rebase = false, bool autostash = false) {
|
||||
public void Pull(string remote, string branch, string submod, Action<string> onProgress, bool rebase = false, bool autostash = false) {
|
||||
isWatcherDisabled = true;
|
||||
|
||||
var args = "-c credential.helper=manager pull --verbose --progress ";
|
||||
var args = $"-c credential.helper=manager pull --verbose --progress {submod} ";
|
||||
var needPopStash = false;
|
||||
|
||||
if (rebase) args += "--rebase ";
|
||||
|
@ -518,14 +520,15 @@ namespace SourceGit.Git {
|
|||
/// <param name="remote">Remote</param>
|
||||
/// <param name="localBranch">Local branch name</param>
|
||||
/// <param name="remoteBranch">Remote branch name</param>
|
||||
/// <param name="submod">submod</param>
|
||||
/// <param name="onProgress">Progress message handler.</param>
|
||||
/// <param name="withTags">Push tags</param>
|
||||
/// <param name="track">Create track reference</param>
|
||||
/// <param name="force">Force push</param>
|
||||
public void Push(string remote, string localBranch, string remoteBranch, Action<string> onProgress, bool withTags = false, bool track = false, bool force = false) {
|
||||
public void Push(string remote, string localBranch, string remoteBranch, string submod, Action<string> onProgress, bool withTags = false, bool track = false, bool force = false) {
|
||||
isWatcherDisabled = true;
|
||||
|
||||
var args = "-c credential.helper=manager push --progress --verbose ";
|
||||
var args = $"-c credential.helper=manager push --progress --verbose {submod} ";
|
||||
|
||||
if (withTags) args += "--tags ";
|
||||
if (track) args += "-u ";
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
xmlns:git="clr-namespace:SourceGit.Git"
|
||||
xmlns:converters="clr-namespace:SourceGit.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="192" d:DesignWidth="500" Height="192" Width="500">
|
||||
d:DesignHeight="192" d:DesignWidth="500" Height="224" Width="500">
|
||||
<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>
|
||||
|
@ -41,17 +42,24 @@
|
|||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<CheckBox Grid.Row="3" Grid.Column="1"
|
||||
<Label Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right" Content="Recurse Submodules :"/>
|
||||
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
|
||||
<RadioButton x:Name="RbtnRrsSubModYes" Content="Yes" GroupName="RecurseSubmodules"/>
|
||||
<RadioButton x:Name="RbtnRrsSubModDemand" Content="On-Demand" Margin="8,0,0,0" GroupName="RecurseSubmodules" IsChecked="True"/>
|
||||
<RadioButton x:Name="RbtnRrsSubModNo" Content="No" Margin="8,0,0,0" GroupName="RecurseSubmodules"/>
|
||||
</StackPanel>
|
||||
|
||||
<CheckBox Grid.Row="4" Grid.Column="1"
|
||||
x:Name="chkFetchAll"
|
||||
IsChecked="True"
|
||||
Content="Fetch all remotes"/>
|
||||
|
||||
<CheckBox Grid.Row="4" Grid.Column="1"
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
x:Name="chkPrune"
|
||||
IsChecked="True"
|
||||
Content="Prune remote dead branches"/>
|
||||
|
||||
<Grid Grid.Row="6" Grid.ColumnSpan="2">
|
||||
<Grid Grid.Row="7" Grid.ColumnSpan="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="80"/>
|
||||
|
|
|
@ -49,15 +49,24 @@ namespace SourceGit.UI {
|
|||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private async void Start(object sender, RoutedEventArgs e) {
|
||||
bool prune = chkPrune.IsChecked == true;
|
||||
bool prune = chkPrune.IsChecked == true;
|
||||
|
||||
string subMod;
|
||||
if (RbtnRrsSubModYes.IsChecked == true) {
|
||||
subMod = "--recurse-submodules=yes";
|
||||
} else if (RbtnRrsSubModNo.IsChecked == true) {
|
||||
subMod = "--recurse-submodules=no";
|
||||
} else {
|
||||
subMod = "--recurse-submodules=on-demand";
|
||||
}
|
||||
|
||||
PopupManager.Lock();
|
||||
|
||||
if (chkFetchAll.IsChecked == true) {
|
||||
await Task.Run(() => repo.Fetch(null, prune, PopupManager.UpdateStatus));
|
||||
await Task.Run(() => repo.Fetch(null, subMod, prune, PopupManager.UpdateStatus));
|
||||
} else {
|
||||
var remote = combRemotes.SelectedItem as Git.Remote;
|
||||
await Task.Run(() => repo.Fetch(remote, prune, PopupManager.UpdateStatus));
|
||||
await Task.Run(() => repo.Fetch(remote, subMod, prune, PopupManager.UpdateStatus));
|
||||
}
|
||||
|
||||
PopupManager.Close(true);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="248" d:DesignWidth="500" Height="248" Width="500">
|
||||
d:DesignHeight="248" d:DesignWidth="500" Height="280" Width="500">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32"/>
|
||||
|
@ -12,6 +12,7 @@
|
|||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="16"/>
|
||||
|
@ -60,19 +61,26 @@
|
|||
<Label x:Name="txtInto" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
<Label Grid.Row="5" Grid.Column="0" HorizontalAlignment="Right" Content="Recurse Submodules :"/>
|
||||
<StackPanel Grid.Row="5" Grid.Column="1" Orientation="Horizontal">
|
||||
<RadioButton x:Name="RbtnRrsSubModYes" Content="Yes" GroupName="RecurseSubmodules"/>
|
||||
<RadioButton x:Name="RbtnRrsSubModDemand" Content="On-Demand" Margin="8,0,0,0" GroupName="RecurseSubmodules" IsChecked="True"/>
|
||||
<RadioButton x:Name="RbtnRrsSubModNo" Content="No" Margin="8,0,0,0" GroupName="RecurseSubmodules"/>
|
||||
</StackPanel>
|
||||
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
x:Name="chkRebase"
|
||||
IsChecked="True"
|
||||
VerticalAlignment="Center"
|
||||
Content="Use rebase instead of merge"/>
|
||||
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
<CheckBox Grid.Row="7" Grid.Column="1"
|
||||
x:Name="chkAutoStash"
|
||||
IsChecked="True"
|
||||
VerticalAlignment="Center"
|
||||
Content="Stash & reapply local changes"/>
|
||||
|
||||
<Grid Grid.Row="8" Grid.ColumnSpan="2">
|
||||
<Grid Grid.Row="9" Grid.ColumnSpan="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="80"/>
|
||||
|
|
|
@ -76,8 +76,17 @@ namespace SourceGit.UI {
|
|||
|
||||
if (remote == null || branch == null) return;
|
||||
|
||||
string subMod;
|
||||
if (RbtnRrsSubModYes.IsChecked == true) {
|
||||
subMod = "--recurse-submodules=yes";
|
||||
} else if (RbtnRrsSubModNo.IsChecked == true) {
|
||||
subMod = "--recurse-submodules=no";
|
||||
} else {
|
||||
subMod = "--recurse-submodules=on-demand";
|
||||
}
|
||||
|
||||
PopupManager.Lock();
|
||||
await Task.Run(() => repo.Pull(remote, branch.Substring(branch.IndexOf('/')+1), PopupManager.UpdateStatus, rebase, autoStash));
|
||||
await Task.Run(() => repo.Pull(remote, branch.Substring(branch.IndexOf('/')+1), subMod, PopupManager.UpdateStatus, rebase, autoStash));
|
||||
PopupManager.Close(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:git="clr-namespace:SourceGit.Git"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="248" d:DesignWidth="500" Height="248" Width="500">
|
||||
d:DesignHeight="248" d:DesignWidth="500" Height="280" Width="500">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32"/>
|
||||
|
@ -13,6 +13,7 @@
|
|||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="16"/>
|
||||
|
@ -70,17 +71,25 @@
|
|||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
<Label Grid.Row="5" Grid.Column="0" HorizontalAlignment="Right" Content="Recurse Submodules :"/>
|
||||
<StackPanel Grid.Row="5" Grid.Column="1" Orientation="Horizontal">
|
||||
<RadioButton x:Name="RbtnRrsSubModCheck" Content="Check" GroupName="RecurseSubmodules"/>
|
||||
<RadioButton x:Name="RbtnRrsSubModDemand" Content="On-Demand" Margin="8,0,0,0" GroupName="RecurseSubmodules" />
|
||||
<RadioButton x:Name="RbtnRrsSubModOnly" Content="Only" Margin="8,0,0,0" GroupName="RecurseSubmodules"/>
|
||||
<RadioButton x:Name="RbtnRrsSubModNo" Content="No" Margin="8,0,0,0" GroupName="RecurseSubmodules" IsChecked="True"/>
|
||||
</StackPanel>
|
||||
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
x:Name="chkTags"
|
||||
VerticalAlignment="Center"
|
||||
Content="Push all tags"/>
|
||||
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
<CheckBox Grid.Row="7" Grid.Column="1"
|
||||
x:Name="chkForce"
|
||||
VerticalAlignment="Center"
|
||||
Content="Force push"/>
|
||||
|
||||
<Grid Grid.Row="8" Grid.ColumnSpan="2">
|
||||
<Grid Grid.Row="9" Grid.ColumnSpan="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="80"/>
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace SourceGit.UI {
|
|||
var remoteBranch = upstream.Substring(remoteIdx + 1);
|
||||
|
||||
Task.Run(() => {
|
||||
repo.Push(remote, current.Name, remoteBranch, PopupManager.UpdateStatus);
|
||||
repo.Push(remote, current.Name, remoteBranch, "--recurse-submodules=no", PopupManager.UpdateStatus);
|
||||
push.Dispatcher.Invoke(() => {
|
||||
PopupManager.Close(true);
|
||||
});
|
||||
|
@ -89,7 +89,19 @@ namespace SourceGit.UI {
|
|||
var remoteBranch = combRemoteBranches.SelectedItem as string;
|
||||
var track = string.IsNullOrEmpty(localBranch.Upstream);
|
||||
var tags = chkTags.IsChecked == true;
|
||||
var force = chkForce.IsChecked == true;
|
||||
var force = chkForce.IsChecked == true;
|
||||
|
||||
string subMod;
|
||||
if (RbtnRrsSubModCheck.IsChecked == true) {
|
||||
subMod = "--recurse-submodules=check";
|
||||
} else if (RbtnRrsSubModDemand.IsChecked == true) {
|
||||
subMod = "--recurse-submodules=on-demand";
|
||||
}
|
||||
else if (RbtnRrsSubModOnly.IsChecked == true) {
|
||||
subMod = "--recurse-submodules=only";
|
||||
} else{
|
||||
subMod = "--recurse-submodules=no";
|
||||
}
|
||||
|
||||
remoteBranch = remoteBranch.Substring($"{remote}/".Length);
|
||||
if (remoteBranch.Contains(" (new)")) {
|
||||
|
@ -97,7 +109,7 @@ namespace SourceGit.UI {
|
|||
}
|
||||
|
||||
PopupManager.Lock();
|
||||
await Task.Run(() => repo.Push(remote, localBranch.Name, remoteBranch, PopupManager.UpdateStatus, tags, track, force));
|
||||
await Task.Run(() => repo.Push(remote, localBranch.Name, remoteBranch, subMod, PopupManager.UpdateStatus, tags, track, force));
|
||||
PopupManager.Close(true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue