mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
feature<SubTree>: supports git subtree
feature
This commit is contained in:
parent
6b602e70c5
commit
130b5a66ab
22 changed files with 784 additions and 10 deletions
39
src/Commands/SubTree.cs
Normal file
39
src/Commands/SubTree.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue