diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index bfeb261c..7884a14d 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -135,6 +135,7 @@
SHA
Subject
Custom Action
+ Drop Commit
Interactive Rebase
Drop...
Edit...
@@ -355,6 +356,9 @@
Include untracked files
{0} changes will be discarded
You can't undo this action!!!
+ Drop Commit
+ Commit:
+ New HEAD:
Bookmark:
New Name:
Target:
diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml
index 18606ff8..cc3b0454 100644
--- a/src/Resources/Locales/zh_CN.axaml
+++ b/src/Resources/Locales/zh_CN.axaml
@@ -139,6 +139,7 @@
提交指纹
主题
自定义操作
+ 丢弃此提交
交互式变基(rebase -i)
丢弃...
编辑...
@@ -359,6 +360,9 @@
包括未跟踪的文件
总计{0}项选中更改
本操作不支持回退,请确认后继续!!!
+ 丢弃提交
+ 提交 :
+ 丢弃后 HEAD :
书签 :
名称 :
目标 :
diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml
index 11a4e5ae..14c7509c 100644
--- a/src/Resources/Locales/zh_TW.axaml
+++ b/src/Resources/Locales/zh_TW.axaml
@@ -139,6 +139,7 @@
提交編號
標題
自訂動作
+ 捨棄此提交
互動式重定基底 (rebase -i)
捨棄...
編輯...
@@ -359,6 +360,9 @@
包含未追蹤檔案
將捨棄總計 {0} 項已選取的變更
您無法復原此操作,請確認後再繼續!
+ 捨棄提交
+ 提交 :
+ 捨棄後新的 HEAD :
書籤:
名稱:
目標:
diff --git a/src/ViewModels/DropHead.cs b/src/ViewModels/DropHead.cs
new file mode 100644
index 00000000..b5baed06
--- /dev/null
+++ b/src/ViewModels/DropHead.cs
@@ -0,0 +1,63 @@
+using System.Threading.Tasks;
+
+namespace SourceGit.ViewModels
+{
+ public class DropHead : Popup
+ {
+ public Models.Commit Target
+ {
+ get;
+ }
+
+ public Models.Commit NewHead
+ {
+ get;
+ }
+
+ public DropHead(Repository repo, Models.Commit target, Models.Commit parent)
+ {
+ _repo = repo;
+ Target = target;
+ NewHead = parent;
+ }
+
+ public override async Task Sure()
+ {
+ using var lockWatcher = _repo.LockWatcher();
+ ProgressDescription = $"Drop HEAD '{Target.SHA}' ...";
+
+ var log = _repo.CreateLog($"Drop '{Target.SHA}'");
+ Use(log);
+
+ var changes = await new Commands.QueryLocalChanges(_repo.FullPath, true).GetResultAsync();
+ var needAutoStash = changes.Count > 0;
+ var succ = false;
+
+ if (needAutoStash)
+ {
+ succ = await new Commands.Stash(_repo.FullPath)
+ .Use(log)
+ .PushAsync("DROP_HEAD_AUTO_STASH", true);
+ if (!succ)
+ {
+ log.Complete();
+ return false;
+ }
+ }
+
+ succ = await new Commands.Reset(_repo.FullPath, NewHead.SHA, "--hard")
+ .Use(log)
+ .ExecAsync();
+
+ if (succ && needAutoStash)
+ await new Commands.Stash(_repo.FullPath)
+ .Use(log)
+ .PopAsync("stash@{0}");
+
+ log.Complete();
+ return succ;
+ }
+
+ private readonly Repository _repo;
+ }
+}
diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs
index 7f9e540a..3ad35596 100644
--- a/src/ViewModels/Histories.cs
+++ b/src/ViewModels/Histories.cs
@@ -332,6 +332,16 @@ namespace SourceGit.ViewModels
}
}
+ public async Task DropHeadAsync(Models.Commit head)
+ {
+ var parent = _commits.Find(x => x.SHA.Equals(head.Parents[0]));
+ if (parent == null)
+ parent = await new Commands.QuerySingleCommit(_repo.FullPath, head.Parents[0]).GetResultAsync();
+
+ if (parent != null && _repo.CanCreatePopup())
+ _repo.ShowPopup(new DropHead(_repo, head, parent));
+ }
+
public async Task InteractiveRebaseAsync(Models.Commit commit, Models.InteractiveRebaseAction act)
{
var prefill = new InteractiveRebasePrefill(commit.SHA, act);
diff --git a/src/Views/DropHead.axaml b/src/Views/DropHead.axaml
new file mode 100644
index 00000000..a7f9fd14
--- /dev/null
+++ b/src/Views/DropHead.axaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Views/DropHead.axaml.cs b/src/Views/DropHead.axaml.cs
new file mode 100644
index 00000000..5dc43cf1
--- /dev/null
+++ b/src/Views/DropHead.axaml.cs
@@ -0,0 +1,12 @@
+using Avalonia.Controls;
+
+namespace SourceGit.Views
+{
+ public partial class DropHead : UserControl
+ {
+ public DropHead()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs
index e6cca699..b0cef55d 100644
--- a/src/Views/Histories.axaml.cs
+++ b/src/Views/Histories.axaml.cs
@@ -610,7 +610,19 @@ namespace SourceGit.Views
};
menu.Items.Add(revert);
- if (!isHead)
+ if (isHead)
+ {
+ var dropHead = new MenuItem();
+ dropHead.Header = App.Text("CommitCM.Drop");
+ dropHead.Icon = App.CreateMenuIcon("Icons.Clear");
+ dropHead.Click += async (_, e) =>
+ {
+ await vm.DropHeadAsync(commit);
+ e.Handled = true;
+ };
+ menu.Items.Add(dropHead);
+ }
+ else
{
var checkoutCommit = new MenuItem();
checkoutCommit.Header = App.Text("CommitCM.Checkout");