Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/Commands/Stash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,27 @@ public bool PushOnlyStaged(string message, bool keepIndex)
return Exec();
}

public bool Apply(string name)
public bool Apply(string name = null)
{
Args = $"stash apply --index -q {name}";
Args = "stash apply -q";
if (!string.IsNullOrEmpty(name))
Args += $" \"{name}\"";
return Exec();
}

public bool Pop(string name)
public bool Pop(string name = null)
{
Args = $"stash pop --index -q {name}";
Args = "stash pop -q";
if (!string.IsNullOrEmpty(name))
Args += $" \"{name}\"";
return Exec();
}

public bool Drop(string name)
public bool Drop(string name = null)
{
Args = $"stash drop -q {name}";
Args = "stash drop -q";
if (!string.IsNullOrEmpty(name))
Args += $" \"{name}\"";
return Exec();
}

Expand Down
6 changes: 6 additions & 0 deletions src/Models/RepositorySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ public bool KeepIndexWhenStash
set;
} = false;

public bool AutoRestoreAfterStash
{
get;
set;
} = false;

public string PreferedOpenAIService
{
get;
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/Locales/en_US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@
<x:String x:Key="Text.SSHKey.Placeholder" xml:space="preserve">Private SSH key store path</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.AutoRestore" xml:space="preserve">Auto-restore after stashing</x:String>
<x:String x:Key="Text.Stash.AutoRestore.Tip" xml:space="preserve">Your working files remain unchanged, but a stash is saved.</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>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/Locales/zh_CN.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,8 @@
<x:String x:Key="Text.SSHKey.Placeholder" xml:space="preserve">SSH密钥文件</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.AutoRestore" xml:space="preserve">贮藏后自动恢复工作区</x:String>
<x:String x:Key="Text.Stash.AutoRestore.Tip" 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>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/Locales/zh_TW.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,8 @@
<x:String x:Key="Text.SSHKey.Placeholder" xml:space="preserve">SSH 金鑰檔案</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.AutoRestore" xml:space="preserve">暫存後自動復原工作區</x:String>
<x:String x:Key="Text.Stash.AutoRestore.Tip" 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>
Expand Down
9 changes: 9 additions & 0 deletions src/ViewModels/StashChanges.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public bool KeepIndex
set => _repo.Settings.KeepIndexWhenStash = value;
}

public bool AutoRestore
{
get => _repo.Settings.AutoRestoreAfterStash;
set => _repo.Settings.AutoRestoreAfterStash = value;
}

public StashChanges(Repository repo, List<Models.Change> changes, bool hasSelectedFiles)
{
_repo = repo;
Expand Down Expand Up @@ -84,6 +90,9 @@ public override Task<bool> Sure()
succ = StashWithChanges(_changes);
}

if (AutoRestore && succ)
succ = new Commands.Stash(_repo.FullPath).Apply();

CallUIThread(() =>
{
_repo.MarkWorkingCopyDirtyManually();
Expand Down
10 changes: 8 additions & 2 deletions src/Views/StashChanges.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<TextBlock FontSize="18"
Classes="bold"
Text="{DynamicResource Text.Stash.Title}"/>
<Grid Margin="8,16,0,0" RowDefinitions="32,Auto,Auto,32,Auto" ColumnDefinitions="120,*">
<Grid Margin="8,16,0,0" RowDefinitions="32,Auto,Auto,32,Auto,Auto" ColumnDefinitions="120,*">
<TextBlock Grid.Row="0" Grid.Column="0"
HorizontalAlignment="Right"
Margin="8,0"
Expand Down Expand Up @@ -43,7 +43,13 @@
IsChecked="{Binding KeepIndex, Mode=TwoWay}"
ToolTip.Tip="--keep-index"/>

<TextBlock Grid.Row="4" Grid.Column="1"
<CheckBox Grid.Row="4" Grid.Column="1"
Height="32"
Content="{DynamicResource Text.Stash.AutoRestore}"
IsChecked="{Binding AutoRestore, Mode=TwoWay}"
ToolTip.Tip="{DynamicResource Text.Stash.AutoRestore.Tip}"/>

<TextBlock Grid.Row="5" Grid.Column="1"
Margin="0,4,0,0"
Text="{DynamicResource Text.Stash.TipForSelectedFiles}"
TextWrapping="Wrap"
Expand Down