diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 172d8ae2..0cc0f0a1 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -562,6 +562,8 @@ Include untracked files Message: Optional. Name of this stash + Only staged changes + Both staged and unstaged changes of selected file(s) will be stashed!!! Stash Local Changes Apply Drop diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 62178b51..fe93e7d1 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -560,6 +560,8 @@ 包含未跟踪的文件 信息 : 选填,用于命名此贮藏 + 仅贮藏暂存区的变更 + 选中文件的所有变更均会被贮藏! 贮藏本地变更 应用(apply) 删除(drop) diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 1d16bde9..a75c1441 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -565,6 +565,8 @@ 包含未追蹤的檔案 擱置變更訊息: 選填,用於命名此擱置變更 + 僅擱置已暫存的變更 + 選中檔案的所有變更均會被擱置! 擱置本機變更 套用 (apply) 刪除 (drop) diff --git a/src/ViewModels/StashChanges.cs b/src/ViewModels/StashChanges.cs index abc45492..ed3d2bfd 100644 --- a/src/ViewModels/StashChanges.cs +++ b/src/ViewModels/StashChanges.cs @@ -11,7 +11,7 @@ namespace SourceGit.ViewModels set; } - public bool CanIgnoreUntracked + public bool HasSelectedFiles { get; } @@ -22,21 +22,28 @@ namespace SourceGit.ViewModels set; } - public StashChanges(Repository repo, List changes, bool onlyStaged, bool canIgnoreUntracked) + public bool OnlyStaged + { + get; + set; + } + + public StashChanges(Repository repo, List changes, bool hasSelectedFiles) { _repo = repo; _changes = changes; - _onlyStaged = onlyStaged; - CanIgnoreUntracked = canIgnoreUntracked; + HasSelectedFiles = hasSelectedFiles; IncludeUntracked = true; + OnlyStaged = false; + View = new Views.StashChanges() { DataContext = this }; } public override Task Sure() { var jobs = _changes; - if (CanIgnoreUntracked && !IncludeUntracked) + if (!HasSelectedFiles && !IncludeUntracked) { jobs = new List(); foreach (var job in _changes) @@ -56,7 +63,7 @@ namespace SourceGit.ViewModels return Task.Run(() => { - var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, _onlyStaged); + var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, !HasSelectedFiles && OnlyStaged); CallUIThread(() => { _repo.MarkWorkingCopyDirtyManually(); @@ -68,6 +75,5 @@ namespace SourceGit.ViewModels private readonly Repository _repo = null; private readonly List _changes = null; - private readonly bool _onlyStaged = false; } } diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 4bfb10bc..e4acf8ca 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -318,9 +318,9 @@ namespace SourceGit.ViewModels return; if (autoStart) - PopupHost.ShowAndStartPopup(new StashChanges(_repo, _cached, false, true)); + PopupHost.ShowAndStartPopup(new StashChanges(_repo, _cached, false)); else - PopupHost.ShowPopup(new StashChanges(_repo, _cached, false, true)); + PopupHost.ShowPopup(new StashChanges(_repo, _cached, false)); } public void StageSelected(Models.Change next) @@ -523,9 +523,8 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - { - PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false, false)); - } + PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, true)); + e.Handled = true; }; @@ -843,7 +842,7 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false, false)); + PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, true)); e.Handled = true; }; @@ -928,7 +927,7 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true, false)); + PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true)); e.Handled = true; }; @@ -1097,7 +1096,7 @@ namespace SourceGit.ViewModels stash.Click += (_, e) => { if (PopupHost.CanCreatePopup()) - PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true, false)); + PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true)); e.Handled = true; }; diff --git a/src/Views/StashChanges.axaml b/src/Views/StashChanges.axaml index 95299ff1..5396da4d 100644 --- a/src/Views/StashChanges.axaml +++ b/src/Views/StashChanges.axaml @@ -11,7 +11,7 @@ - + + + + IsVisible="{Binding !HasSelectedFiles}"/> + +