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
44
src/Commands/Submodule.cs
Normal file
44
src/Commands/Submodule.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
|
||||
namespace SourceGit.Commands {
|
||||
/// <summary>
|
||||
/// 子模块
|
||||
/// </summary>
|
||||
public class Submodule : Command {
|
||||
private Action<string> onProgress = null;
|
||||
|
||||
public Submodule(string cwd) {
|
||||
Cwd = cwd;
|
||||
}
|
||||
|
||||
public bool Add(string url, string path, bool recursive, Action<string> handler) {
|
||||
Args = $"submodule add {url} {path}";
|
||||
onProgress = handler;
|
||||
if (!Exec()) return false;
|
||||
|
||||
if (recursive) {
|
||||
Args = $"submodule update --init --recursive -- {path}";
|
||||
return Exec();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Update() {
|
||||
Args = $"submodule update --rebase --remote";
|
||||
return Exec();
|
||||
}
|
||||
|
||||
public bool Delete(string path) {
|
||||
Args = $"submodule deinit -f {path}";
|
||||
if (!Exec()) return false;
|
||||
|
||||
Args = $"rm -rf {path}";
|
||||
return Exec();
|
||||
}
|
||||
|
||||
public override void OnReadline(string line) {
|
||||
onProgress?.Invoke(line);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue