mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: add option to enable --keep-index
option of git stash push
command (#610)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
3e6e0befaa
commit
566d36ca59
6 changed files with 22 additions and 5 deletions
|
@ -17,17 +17,19 @@ namespace SourceGit.Commands
|
||||||
return Exec();
|
return Exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Push(List<Models.Change> changes, string message, bool onlyStaged)
|
public bool Push(List<Models.Change> changes, string message, bool onlyStaged, bool keepIndex)
|
||||||
{
|
{
|
||||||
var pathsBuilder = new StringBuilder();
|
var pathsBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
var indexOpts = keepIndex ? "--keep-index" : "";
|
||||||
|
|
||||||
if (onlyStaged)
|
if (onlyStaged)
|
||||||
{
|
{
|
||||||
foreach (var c in changes)
|
foreach (var c in changes)
|
||||||
pathsBuilder.Append($"\"{c.Path}\" ");
|
pathsBuilder.Append($"\"{c.Path}\" ");
|
||||||
|
|
||||||
var paths = pathsBuilder.ToString();
|
var paths = pathsBuilder.ToString();
|
||||||
Args = $"stash push --staged -m \"{message}\" -- {paths}";
|
Args = $"stash push {indexOpts} --staged -m \"{message}\" -- {paths}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -53,7 +55,7 @@ namespace SourceGit.Commands
|
||||||
}
|
}
|
||||||
|
|
||||||
var paths = pathsBuilder.ToString();
|
var paths = pathsBuilder.ToString();
|
||||||
Args = $"stash push -m \"{message}\" -- {paths}";
|
Args = $"stash push {indexOpts} -m \"{message}\" -- {paths}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return Exec();
|
return Exec();
|
||||||
|
|
|
@ -573,6 +573,7 @@
|
||||||
<x:String x:Key="Text.Start" xml:space="preserve">START</x:String>
|
<x:String x:Key="Text.Start" xml:space="preserve">START</x:String>
|
||||||
<x:String x:Key="Text.Stash" xml:space="preserve">Stash</x:String>
|
<x:String x:Key="Text.Stash" xml:space="preserve">Stash</x:String>
|
||||||
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">Include untracked files</x:String>
|
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">Include untracked files</x:String>
|
||||||
|
<x:String x:Key="Text.Stash.KeepIndex" xml:space="preserve">Keep staged files</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message" xml:space="preserve">Message:</x:String>
|
<x:String x:Key="Text.Stash.Message" xml:space="preserve">Message:</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">Optional. Name of this stash</x:String>
|
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">Optional. Name of this stash</x:String>
|
||||||
<x:String x:Key="Text.Stash.OnlyStagedChanges" xml:space="preserve">Only staged changes</x:String>
|
<x:String x:Key="Text.Stash.OnlyStagedChanges" xml:space="preserve">Only staged changes</x:String>
|
||||||
|
|
|
@ -576,6 +576,7 @@
|
||||||
<x:String x:Key="Text.Start" xml:space="preserve">开 始</x:String>
|
<x:String x:Key="Text.Start" xml:space="preserve">开 始</x:String>
|
||||||
<x:String x:Key="Text.Stash" xml:space="preserve">贮藏(stash)</x:String>
|
<x:String x:Key="Text.Stash" xml:space="preserve">贮藏(stash)</x:String>
|
||||||
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">包含未跟踪的文件</x:String>
|
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">包含未跟踪的文件</x:String>
|
||||||
|
<x:String x:Key="Text.Stash.KeepIndex" xml:space="preserve">保留暂存区文件</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message" xml:space="preserve">信息 :</x:String>
|
<x:String x:Key="Text.Stash.Message" xml:space="preserve">信息 :</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">选填,用于命名此贮藏</x:String>
|
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">选填,用于命名此贮藏</x:String>
|
||||||
<x:String x:Key="Text.Stash.OnlyStagedChanges" xml:space="preserve">仅贮藏暂存区的变更</x:String>
|
<x:String x:Key="Text.Stash.OnlyStagedChanges" xml:space="preserve">仅贮藏暂存区的变更</x:String>
|
||||||
|
|
|
@ -576,6 +576,7 @@
|
||||||
<x:String x:Key="Text.Start" xml:space="preserve">開 始</x:String>
|
<x:String x:Key="Text.Start" xml:space="preserve">開 始</x:String>
|
||||||
<x:String x:Key="Text.Stash" xml:space="preserve">擱置變更 (stash)</x:String>
|
<x:String x:Key="Text.Stash" xml:space="preserve">擱置變更 (stash)</x:String>
|
||||||
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">包含未追蹤的檔案</x:String>
|
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">包含未追蹤的檔案</x:String>
|
||||||
|
<x:String x:Key="Text.Stash.KeepIndex" xml:space="preserve">保留已暫存的變更</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message" xml:space="preserve">擱置變更訊息:</x:String>
|
<x:String x:Key="Text.Stash.Message" xml:space="preserve">擱置變更訊息:</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">選填,用於命名此擱置變更</x:String>
|
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">選填,用於命名此擱置變更</x:String>
|
||||||
<x:String x:Key="Text.Stash.OnlyStagedChanges" xml:space="preserve">僅擱置已暫存的變更</x:String>
|
<x:String x:Key="Text.Stash.OnlyStagedChanges" xml:space="preserve">僅擱置已暫存的變更</x:String>
|
||||||
|
|
|
@ -28,6 +28,12 @@ namespace SourceGit.ViewModels
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool KeepIndex
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
public StashChanges(Repository repo, List<Models.Change> changes, bool hasSelectedFiles)
|
public StashChanges(Repository repo, List<Models.Change> changes, bool hasSelectedFiles)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
|
@ -36,6 +42,7 @@ namespace SourceGit.ViewModels
|
||||||
HasSelectedFiles = hasSelectedFiles;
|
HasSelectedFiles = hasSelectedFiles;
|
||||||
IncludeUntracked = true;
|
IncludeUntracked = true;
|
||||||
OnlyStaged = false;
|
OnlyStaged = false;
|
||||||
|
KeepIndex = false;
|
||||||
|
|
||||||
View = new Views.StashChanges() { DataContext = this };
|
View = new Views.StashChanges() { DataContext = this };
|
||||||
}
|
}
|
||||||
|
@ -63,7 +70,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, !HasSelectedFiles && OnlyStaged);
|
var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, !HasSelectedFiles && OnlyStaged, KeepIndex);
|
||||||
CallUIThread(() =>
|
CallUIThread(() =>
|
||||||
{
|
{
|
||||||
_repo.MarkWorkingCopyDirtyManually();
|
_repo.MarkWorkingCopyDirtyManually();
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<TextBlock FontSize="18"
|
<TextBlock FontSize="18"
|
||||||
Classes="bold"
|
Classes="bold"
|
||||||
Text="{DynamicResource Text.Stash.Title}"/>
|
Text="{DynamicResource Text.Stash.Title}"/>
|
||||||
<Grid Margin="8,16,0,0" RowDefinitions="32,Auto,Auto" ColumnDefinitions="120,*">
|
<Grid Margin="8,16,0,0" RowDefinitions="32,Auto,Auto,32" ColumnDefinitions="120,*">
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Margin="8,0"
|
Margin="8,0"
|
||||||
|
@ -41,6 +41,11 @@
|
||||||
Content="{DynamicResource Text.Stash.OnlyStagedChanges}"
|
Content="{DynamicResource Text.Stash.OnlyStagedChanges}"
|
||||||
IsChecked="{Binding OnlyStaged, Mode=TwoWay}"
|
IsChecked="{Binding OnlyStaged, Mode=TwoWay}"
|
||||||
IsVisible="{Binding !HasSelectedFiles}"/>
|
IsVisible="{Binding !HasSelectedFiles}"/>
|
||||||
|
|
||||||
|
<CheckBox Grid.Row="3" Grid.Column="1"
|
||||||
|
Height="32"
|
||||||
|
Content="{DynamicResource Text.Stash.KeepIndex}"
|
||||||
|
IsChecked="{Binding KeepIndex, Mode=TwoWay}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
Loading…
Reference in a new issue