mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
96d4150d26
* remove dotnet-tool.json because the project does not rely on any dotnet tools. * remove Directory.Build.props because the solution has only one project. * move src/SourceGit to src. It's not needed to put all sources into a subfolder of src since there's only one project.
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
namespace SourceGit.Commands
|
|
{
|
|
public static class Branch
|
|
{
|
|
public static bool Create(string repo, string name, string basedOn)
|
|
{
|
|
var cmd = new Command();
|
|
cmd.WorkingDirectory = repo;
|
|
cmd.Context = repo;
|
|
cmd.Args = $"branch {name} {basedOn}";
|
|
return cmd.Exec();
|
|
}
|
|
|
|
public static bool Rename(string repo, string name, string to)
|
|
{
|
|
var cmd = new Command();
|
|
cmd.WorkingDirectory = repo;
|
|
cmd.Context = repo;
|
|
cmd.Args = $"branch -M {name} {to}";
|
|
return cmd.Exec();
|
|
}
|
|
|
|
public static bool SetUpstream(string repo, string name, string upstream)
|
|
{
|
|
var cmd = new Command();
|
|
cmd.WorkingDirectory = repo;
|
|
cmd.Context = repo;
|
|
if (string.IsNullOrEmpty(upstream))
|
|
{
|
|
cmd.Args = $"branch {name} --unset-upstream";
|
|
}
|
|
else
|
|
{
|
|
cmd.Args = $"branch {name} -u {upstream}";
|
|
}
|
|
return cmd.Exec();
|
|
}
|
|
|
|
public static bool Delete(string repo, string name)
|
|
{
|
|
var cmd = new Command();
|
|
cmd.WorkingDirectory = repo;
|
|
cmd.Context = repo;
|
|
cmd.Args = $"branch -D {name}";
|
|
return cmd.Exec();
|
|
}
|
|
}
|
|
}
|