mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
enhance: try to get stopped at revision info from .git/rebase-merge/head
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
773e27fda7
commit
ca6d41ee60
2 changed files with 36 additions and 10 deletions
21
src/Commands/QueryRevisionByRefName.cs
Normal file
21
src/Commands/QueryRevisionByRefName.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
namespace SourceGit.Commands
|
||||||
|
{
|
||||||
|
public class QueryRevisionByRefName : Command
|
||||||
|
{
|
||||||
|
public QueryRevisionByRefName(string repo, string refname)
|
||||||
|
{
|
||||||
|
WorkingDirectory = repo;
|
||||||
|
Context = repo;
|
||||||
|
Args = $"rev-parse {refname}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Result()
|
||||||
|
{
|
||||||
|
var rs = ReadToEnd();
|
||||||
|
if (rs.IsSuccess && !string.IsNullOrEmpty(rs.StdOut))
|
||||||
|
return rs.StdOut.Trim();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -107,19 +107,24 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
_gitDir = repo.GitDir;
|
_gitDir = repo.GitDir;
|
||||||
|
|
||||||
var stoppedSHAPath = Path.Combine(repo.GitDir, "rebase-merge", "stopped-sha");
|
|
||||||
if (File.Exists(stoppedSHAPath))
|
|
||||||
{
|
|
||||||
var stoppedSHA = File.ReadAllText(stoppedSHAPath).Trim();
|
|
||||||
StoppedAt = new Commands.QuerySingleCommit(repo.FullPath, stoppedSHA).Result() ?? new Models.Commit() { SHA = stoppedSHA };
|
|
||||||
}
|
|
||||||
|
|
||||||
var ontoSHA = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "onto")).Trim();
|
|
||||||
Onto = new Commands.QuerySingleCommit(repo.FullPath, ontoSHA).Result() ?? new Models.Commit() { SHA = ontoSHA };
|
|
||||||
|
|
||||||
HeadName = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "head-name")).Trim();
|
HeadName = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "head-name")).Trim();
|
||||||
if (HeadName.StartsWith("refs/heads/"))
|
if (HeadName.StartsWith("refs/heads/"))
|
||||||
HeadName = HeadName.Substring(11);
|
HeadName = HeadName.Substring(11);
|
||||||
|
else if (HeadName.StartsWith("refs/tags/"))
|
||||||
|
HeadName = HeadName.Substring(10);
|
||||||
|
|
||||||
|
var stoppedSHAPath = Path.Combine(repo.GitDir, "rebase-merge", "stopped-sha");
|
||||||
|
var stoppedSHA = string.Empty;
|
||||||
|
if (File.Exists(stoppedSHAPath))
|
||||||
|
stoppedSHA = File.ReadAllText(stoppedSHAPath).Trim();
|
||||||
|
else
|
||||||
|
stoppedSHA = new Commands.QueryRevisionByRefName(repo.FullPath, HeadName).Result();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(stoppedSHA))
|
||||||
|
StoppedAt = new Commands.QuerySingleCommit(repo.FullPath, stoppedSHA).Result() ?? new Models.Commit() { SHA = stoppedSHA };
|
||||||
|
|
||||||
|
var ontoSHA = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "onto")).Trim();
|
||||||
|
Onto = new Commands.QuerySingleCommit(repo.FullPath, ontoSHA).Result() ?? new Models.Commit() { SHA = ontoSHA };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Continue()
|
public override bool Continue()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue