mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 20:54:59 +00:00
refactor: implementation to delete branches
This commit is contained in:
parent
5eea54dbf8
commit
8fea9fecfb
3 changed files with 27 additions and 29 deletions
|
@ -36,7 +36,7 @@
|
|||
return cmd.Exec();
|
||||
}
|
||||
|
||||
public static bool Delete(string repo, string name)
|
||||
public static bool DeleteLocal(string repo, string name)
|
||||
{
|
||||
var cmd = new Command();
|
||||
cmd.WorkingDirectory = repo;
|
||||
|
@ -44,5 +44,25 @@
|
|||
cmd.Args = $"branch -D {name}";
|
||||
return cmd.Exec();
|
||||
}
|
||||
|
||||
public static bool DeleteRemote(string repo, string remote, string name)
|
||||
{
|
||||
var cmd = new Command();
|
||||
cmd.WorkingDirectory = repo;
|
||||
cmd.Context = repo;
|
||||
|
||||
var sshKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
||||
if (!string.IsNullOrEmpty(sshKey))
|
||||
{
|
||||
cmd.Args = $"-c core.sshCommand=\"ssh -i '{sshKey}'\" ";
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Args = "-c credential.helper=manager ";
|
||||
}
|
||||
|
||||
cmd.Args += $"push {remote} --delete {name}";
|
||||
return cmd.Exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue