diff --git a/src/Commands/QueryBranches.cs b/src/Commands/QueryBranches.cs
index 04241933..ed5282f7 100644
--- a/src/Commands/QueryBranches.cs
+++ b/src/Commands/QueryBranches.cs
@@ -8,6 +8,7 @@ namespace SourceGit.Commands
{
private const string PREFIX_LOCAL = "refs/heads/";
private const string PREFIX_REMOTE = "refs/remotes/";
+ private const string PREFIX_DETACHED = "(HEAD detached at";
[GeneratedRegex(@"^(\d+)\s(\d+)$")]
private static partial Regex REG_AHEAD_BEHIND();
@@ -52,9 +53,9 @@ namespace SourceGit.Commands
if (refName.EndsWith("/HEAD", StringComparison.Ordinal))
return;
- if (refName.StartsWith("(HEAD detached at"))
+ if (refName.StartsWith(PREFIX_DETACHED, StringComparison.Ordinal))
{
- branch.isHead = true;
+ branch.IsHead = true;
}
if (refName.StartsWith(PREFIX_LOCAL, StringComparison.Ordinal))
diff --git a/src/Models/Branch.cs b/src/Models/Branch.cs
index 0b346712..a22ee553 100644
--- a/src/Models/Branch.cs
+++ b/src/Models/Branch.cs
@@ -10,6 +10,6 @@
public string Upstream { get; set; }
public string UpstreamTrackStatus { get; set; }
public string Remote { get; set; }
- public bool isHead { get; set; }
+ public bool IsHead { get; set; }
}
}
diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index ab1f2296..76b18a11 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -56,9 +56,8 @@
Checkout Branch
Checkout Commit
Warning: By doing a commit checkout, your Head will be detached
+ Commit :
Branch :
- Commit SHA :
- Commit Short SHA :
Local Changes :
Stash & Reapply
Discard
diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml
index 7b496f75..310a9aba 100644
--- a/src/Resources/Locales/zh_CN.axaml
+++ b/src/Resources/Locales/zh_CN.axaml
@@ -54,6 +54,9 @@
列表模式
树形模式
检出(checkout)分支
+ 检出(checkout)提交
+ 注意:执行该操作后,当前HEAD会变为游离(detached)状态!
+ 提交 :
目标分支 :
未提交更改 :
贮藏(stash)并自动恢复
@@ -73,6 +76,7 @@
远程仓库 :
关闭
挑选(cherry-pick)此提交
+ 检出提交${0}
复制提交指纹
变基(rebase)${0}$到此处
重置(reset)${0}$到此处
diff --git a/src/SourceGit.csproj b/src/SourceGit.csproj
index 0cc2f21e..657b49f3 100644
--- a/src/SourceGit.csproj
+++ b/src/SourceGit.csproj
@@ -44,11 +44,4 @@
-
-
-
- CheckoutCommit.axaml
- Code
-
-
diff --git a/src/ViewModels/BranchTreeNode.cs b/src/ViewModels/BranchTreeNode.cs
index 79097895..d5690889 100644
--- a/src/ViewModels/BranchTreeNode.cs
+++ b/src/ViewModels/BranchTreeNode.cs
@@ -223,7 +223,7 @@ namespace SourceGit.ViewModels
lastFolder.Children.Add(new BranchTreeNode()
{
Name = Path.GetFileName(branch.Name),
- Type = branch.isHead ? BranchTreeNodeType.DetachedHead : BranchTreeNodeType.Branch,
+ Type = branch.IsHead ? BranchTreeNodeType.DetachedHead : BranchTreeNodeType.Branch,
Backend = branch,
IsExpanded = false,
IsFiltered = isFiltered,
diff --git a/src/ViewModels/CheckoutCommit.cs b/src/ViewModels/CheckoutCommit.cs
index e27537ac..da91f7fb 100644
--- a/src/ViewModels/CheckoutCommit.cs
+++ b/src/ViewModels/CheckoutCommit.cs
@@ -4,7 +4,7 @@ namespace SourceGit.ViewModels
{
public class CheckoutCommit: Popup
{
- public string Commit
+ public Models.Commit Commit
{
get;
private set;
@@ -21,7 +21,7 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _autoStash, value);
}
- public CheckoutCommit(Repository repo, string commit)
+ public CheckoutCommit(Repository repo, Models.Commit commit)
{
_repo = repo;
Commit = commit;
@@ -31,7 +31,7 @@ namespace SourceGit.ViewModels
public override Task Sure()
{
_repo.SetWatcherEnabled(false);
- ProgressDescription = $"Checkout Commit '{Commit}' ...";
+ ProgressDescription = $"Checkout Commit '{Commit.SHA}' ...";
return Task.Run(() =>
{
@@ -64,7 +64,7 @@ namespace SourceGit.ViewModels
}
SetProgressDescription("Checkout commit ...");
- var rs = new Commands.Checkout(_repo.FullPath).Commit(Commit, SetProgressDescription);
+ var rs = new Commands.Checkout(_repo.FullPath).Commit(Commit.SHA, SetProgressDescription);
if (needPopStash)
{
diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs
index 3065bcb0..d1eb05d6 100644
--- a/src/ViewModels/Histories.cs
+++ b/src/ViewModels/Histories.cs
@@ -1,11 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using System.Globalization;
using System.Threading.Tasks;
using Avalonia.Controls;
-using Avalonia.Data.Converters;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
@@ -238,15 +236,11 @@ namespace SourceGit.ViewModels
menu.Items.Add(reset);
var checkoutCommit = new MenuItem();
-
- var shortSha = Converters.StringConverters.ToShortSHA
- .Convert(commit.SHA, typeof(string), null, CultureInfo.CurrentCulture);
-
- checkoutCommit.Header = new Views.NameHighlightedTextBlock("CommitCM.Checkout", shortSha);
+ checkoutCommit.Header = new Views.NameHighlightedTextBlock("CommitCM.Checkout", commit.SHA.Substring(0, 10));
checkoutCommit.Icon = App.CreateMenuIcon("Icons.Check");
checkoutCommit.Click += (o, e) =>
{
- _repo.CheckoutCommit(commit.SHA);
+ _repo.CheckoutCommit(commit);
e.Handled = true;
};
menu.Items.Add(checkoutCommit);
diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs
index d8e5c766..d2ea73fa 100644
--- a/src/ViewModels/Repository.cs
+++ b/src/ViewModels/Repository.cs
@@ -722,7 +722,7 @@ namespace SourceGit.ViewModels
PopupHost.ShowAndStartPopup(new Checkout(this, branch));
}
- public void CheckoutCommit(string commit)
+ public void CheckoutCommit(Models.Commit commit)
{
if (!PopupHost.CanCreatePopup())
return;
diff --git a/src/Views/CheckoutCommit.axaml b/src/Views/CheckoutCommit.axaml
index 70bce62f..d59c4833 100644
--- a/src/Views/CheckoutCommit.axaml
+++ b/src/Views/CheckoutCommit.axaml
@@ -10,36 +10,38 @@
+ Text="{DynamicResource Text.Checkout.Commit}" />
-
-
-
-
-
- ()
-
-
-
-
+
+
+
-
-
+ Text="{DynamicResource Text.Checkout.Commit.Target}" />
+
+
+
+
+
+
+
+
+ IsChecked="{Binding AutoStash, Mode=TwoWay}" />
+ Margin="8,0,0,0" />
-
-
-
+
diff --git a/src/Views/CheckoutCommit.axaml.cs b/src/Views/CheckoutCommit.axaml.cs
index f44fd6c7..375816c9 100644
--- a/src/Views/CheckoutCommit.axaml.cs
+++ b/src/Views/CheckoutCommit.axaml.cs
@@ -4,7 +4,6 @@ namespace SourceGit.Views
{
public partial class CheckoutCommit : UserControl
{
- public bool HasLocalChanges;
public CheckoutCommit()
{
InitializeComponent();