2021-04-29 05:05:55 -07:00
|
|
|
namespace SourceGit.Commands {
|
|
|
|
/// <summary>
|
|
|
|
/// 分支相关操作
|
|
|
|
/// </summary>
|
|
|
|
class Branch : Command {
|
|
|
|
private string target = null;
|
|
|
|
|
|
|
|
public Branch(string repo, string branch) {
|
|
|
|
Cwd = repo;
|
|
|
|
target = branch;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Create(string basedOn) {
|
|
|
|
Args = $"branch {target} {basedOn}";
|
|
|
|
Exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Rename(string to) {
|
|
|
|
Args = $"branch -M {target} {to}";
|
|
|
|
Exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetUpstream(string upstream) {
|
2021-09-06 18:36:06 -07:00
|
|
|
Args = $"branch {target} ";
|
|
|
|
if (string.IsNullOrEmpty(upstream)) {
|
|
|
|
Args += "--unset-upstream";
|
|
|
|
} else {
|
|
|
|
Args += $"-u {upstream}";
|
|
|
|
}
|
2021-04-29 05:05:55 -07:00
|
|
|
Exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Delete() {
|
|
|
|
Args = $"branch -D {target}";
|
|
|
|
Exec();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|