mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-01 01:14:59 +00:00
refactor: rewrite checkout/create branch with submodules
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
e446e97f28
commit
0f6c8976af
8 changed files with 136 additions and 65 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
namespace SourceGit.Commands
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace SourceGit.Commands
|
||||
{
|
||||
public class Submodule : Command
|
||||
{
|
||||
|
@ -42,6 +45,28 @@
|
|||
return Exec();
|
||||
}
|
||||
|
||||
public bool Update(List<Models.Submodule> modules, bool init, bool recursive, bool useRemote)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
builder.Append("submodule update");
|
||||
|
||||
if (init)
|
||||
builder.Append(" --init");
|
||||
if (recursive)
|
||||
builder.Append(" --recursive");
|
||||
if (useRemote)
|
||||
builder.Append(" --remote");
|
||||
if (modules.Count > 0)
|
||||
{
|
||||
builder.Append(" --");
|
||||
foreach (var module in modules)
|
||||
builder.Append($" \"{module.Path}\"");
|
||||
}
|
||||
|
||||
Args = builder.ToString();
|
||||
return Exec();
|
||||
}
|
||||
|
||||
public bool Delete(string relativePath)
|
||||
{
|
||||
Args = $"submodule deinit -f \"{relativePath}\"";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue