mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
refactor<*>: rewrite all codes...
This commit is contained in:
parent
89ff8aa744
commit
30ab8ae954
342 changed files with 17208 additions and 19633 deletions
46
src/Commands/Checkout.cs
Normal file
46
src/Commands/Checkout.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace SourceGit.Commands {
|
||||
/// <summary>
|
||||
/// 检出
|
||||
/// </summary>
|
||||
public class Checkout : Command {
|
||||
|
||||
public Checkout(string repo) {
|
||||
Cwd = repo;
|
||||
}
|
||||
|
||||
public bool Branch(string branch) {
|
||||
Args = $"checkout {branch}";
|
||||
return Exec();
|
||||
}
|
||||
|
||||
public bool Branch(string branch, string basedOn) {
|
||||
Args = $"checkout -b {branch} {basedOn}";
|
||||
return Exec();
|
||||
}
|
||||
|
||||
public bool File(string file, bool useTheirs) {
|
||||
if (useTheirs) {
|
||||
Args = $"checkout --theirs -- \"{file}\"";
|
||||
} else {
|
||||
Args = $"checkout --ours -- \"{file}\"";
|
||||
}
|
||||
|
||||
return Exec();
|
||||
}
|
||||
|
||||
public bool Files(List<string> files) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.Append("checkout -qf --");
|
||||
foreach (var f in files) {
|
||||
builder.Append(" \"");
|
||||
builder.Append(f);
|
||||
builder.Append("\"");
|
||||
}
|
||||
Args = builder.ToString();
|
||||
return Exec();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue