mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
|
using System;
|
||
|
|
||
|
namespace SourceGit.Commands {
|
||
|
/// <summary>
|
||
|
/// 子树相关操作
|
||
|
/// </summary>
|
||
|
public class SubTree : Command {
|
||
|
private Action<string> handler = null;
|
||
|
|
||
|
public SubTree(string repo) {
|
||
|
Cwd = repo;
|
||
|
TraitErrorAsOutput = true;
|
||
|
}
|
||
|
|
||
|
public override void OnReadline(string line) {
|
||
|
handler?.Invoke(line);
|
||
|
}
|
||
|
|
||
|
public bool Add(string prefix, string source, string revision, bool squash, Action<string> onProgress) {
|
||
|
handler = onProgress;
|
||
|
Args = $"subtree add --prefix=\"{prefix}\" {source} {revision}";
|
||
|
if (squash) Args += " --squash";
|
||
|
return Exec();
|
||
|
}
|
||
|
|
||
|
public void Pull(string prefix, string source, string branch, bool squash, Action<string> onProgress) {
|
||
|
handler = onProgress;
|
||
|
Args = $"subtree pull --prefix=\"{prefix}\" {source} {branch}";
|
||
|
if (squash) Args += " --squash";
|
||
|
Exec();
|
||
|
}
|
||
|
|
||
|
public void Push(string prefix, string source, string branch, Action<string> onProgress) {
|
||
|
handler = onProgress;
|
||
|
Args = $"subtree push --prefix=\"{prefix}\" {source} {branch}";
|
||
|
Exec();
|
||
|
}
|
||
|
}
|
||
|
}
|