refactor: rewrite checkout/create branch with submodules

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-05-09 17:51:46 +08:00
parent e446e97f28
commit 0f6c8976af
No known key found for this signature in database
8 changed files with 136 additions and 65 deletions

View file

@ -11,18 +11,27 @@ namespace SourceGit.Commands
Context = repo;
}
public bool Branch(string branch)
public bool Branch(string branch, bool force)
{
Args = $"checkout --progress {branch}";
var option = force ? "--force" : string.Empty;
Args = $"checkout {option} --progress {branch}";
return Exec();
}
public bool Branch(string branch, string basedOn)
public bool Branch(string branch, string basedOn, bool force)
{
var option = force ? "--force" : string.Empty;
Args = $"checkout --progress -b {branch} {basedOn}";
return Exec();
}
public bool Commit(string commitId, bool force)
{
var option = force ? "--force" : string.Empty;
Args = $"checkout {option} --detach --progress {commitId}";
return Exec();
}
public bool UseTheirs(List<string> files)
{
var builder = new StringBuilder();
@ -56,11 +65,5 @@ namespace SourceGit.Commands
Args = $"checkout --no-overlay {revision} -- \"{file}\"";
return Exec();
}
public bool Commit(string commitId)
{
Args = $"checkout --detach --progress {commitId}";
return Exec();
}
}
}