refactor: base command

This commit is contained in:
leo 2024-07-09 18:13:15 +08:00
parent dda1e79c6f
commit 446445ee73
No known key found for this signature in database
7 changed files with 42 additions and 85 deletions

View file

@ -25,14 +25,12 @@
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();
}
@ -50,14 +48,8 @@
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 credential.helper=manager ";
else
cmd.UseSSHKey(sshKey);
cmd.Args += $"push {remote} --delete {name}";
cmd.SSHKey = new Config(repo).Get($"remote.{remote}.sshkey");
cmd.Args = $"push {remote} --delete {name}";
return cmd.Exec();
}
}