Skip to content

Commit bef9980

Browse files
committed
enhance: try to get stopped at revision info from .git/rebase-merge/head
Signed-off-by: leo <longshuang@msn.cn>
1 parent 773e27f commit bef9980

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/ViewModels/InProgressContexts.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,25 @@ public RebaseInProgress(Repository repo) : base(repo.FullPath, "rebase")
107107
{
108108
_gitDir = repo.GitDir;
109109

110+
HeadName = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "head-name")).Trim();
111+
if (HeadName.StartsWith("refs/heads/"))
112+
HeadName = HeadName.Substring(11);
113+
110114
var stoppedSHAPath = Path.Combine(repo.GitDir, "rebase-merge", "stopped-sha");
111115
if (File.Exists(stoppedSHAPath))
112116
{
113117
var stoppedSHA = File.ReadAllText(stoppedSHAPath).Trim();
114118
StoppedAt = new Commands.QuerySingleCommit(repo.FullPath, stoppedSHA).Result() ?? new Models.Commit() { SHA = stoppedSHA };
115119
}
120+
else
121+
{
122+
var b = repo.Branches.Find(x => x.IsLocal && x.Name == HeadName);
123+
if (b != null && !string.IsNullOrEmpty(b.Head))
124+
StoppedAt = new Commands.QuerySingleCommit(repo.FullPath, b.Head).Result() ?? new Models.Commit() { SHA = b.Head };
125+
}
116126

117127
var ontoSHA = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "onto")).Trim();
118128
Onto = new Commands.QuerySingleCommit(repo.FullPath, ontoSHA).Result() ?? new Models.Commit() { SHA = ontoSHA };
119-
120-
HeadName = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "head-name")).Trim();
121-
if (HeadName.StartsWith("refs/heads/"))
122-
HeadName = HeadName.Substring(11);
123129
}
124130

125131
public override bool Continue()

0 commit comments

Comments
 (0)