mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
code_review: PR #1093
Merge deleting branch and tag on remote into `SourceGit.Commands.Push(repo, remote, refname, isDelete)` Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
9645b65db6
commit
c8bee2f6ba
5 changed files with 13 additions and 21 deletions
|
@ -54,21 +54,14 @@
|
||||||
|
|
||||||
public static bool DeleteRemote(string repo, string remote, string name)
|
public static bool DeleteRemote(string repo, string remote, string name)
|
||||||
{
|
{
|
||||||
|
bool exists = new Remote(repo).HasBranch(remote, name);
|
||||||
|
if (exists)
|
||||||
|
return new Push(repo, remote, $"refs/heads/{name}", true).Exec();
|
||||||
|
|
||||||
var cmd = new Command();
|
var cmd = new Command();
|
||||||
cmd.WorkingDirectory = repo;
|
cmd.WorkingDirectory = repo;
|
||||||
cmd.Context = repo;
|
cmd.Context = repo;
|
||||||
|
cmd.Args = $"branch -D -r {remote}/{name}";
|
||||||
bool exists = new Remote(repo).HasBranch(remote, name);
|
|
||||||
if (exists)
|
|
||||||
{
|
|
||||||
cmd.SSHKey = new Config(repo).Get($"remote.{remote}.sshkey");
|
|
||||||
cmd.Args = $"push {remote} --delete refs/heads/{name}";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmd.Args = $"branch -D -r {remote}/{name}";
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmd.Exec();
|
return cmd.Exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace SourceGit.Commands
|
||||||
Args += $"{remote} {local}:{remoteBranch}";
|
Args += $"{remote} {local}:{remoteBranch}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Push(string repo, string remote, string tag, bool isDelete)
|
public Push(string repo, string remote, string refname, bool isDelete)
|
||||||
{
|
{
|
||||||
WorkingDirectory = repo;
|
WorkingDirectory = repo;
|
||||||
Context = repo;
|
Context = repo;
|
||||||
|
@ -36,7 +36,7 @@ namespace SourceGit.Commands
|
||||||
if (isDelete)
|
if (isDelete)
|
||||||
Args += "--delete ";
|
Args += "--delete ";
|
||||||
|
|
||||||
Args += $"{remote} refs/tags/{tag}";
|
Args += $"{remote} {refname}";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnReadline(string line)
|
protected override void OnReadline(string line)
|
||||||
|
|
|
@ -48,9 +48,7 @@ namespace SourceGit.Commands
|
||||||
if (remotes != null)
|
if (remotes != null)
|
||||||
{
|
{
|
||||||
foreach (var r in remotes)
|
foreach (var r in remotes)
|
||||||
{
|
new Push(repo, r.Name, $"refs/tags/{name}", true).Exec();
|
||||||
new Push(repo, r.Name, name, true).Exec();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -96,7 +96,7 @@ namespace SourceGit.ViewModels
|
||||||
foreach (var remote in remotes)
|
foreach (var remote in remotes)
|
||||||
{
|
{
|
||||||
SetProgressDescription($"Pushing tag to remote {remote.Name} ...");
|
SetProgressDescription($"Pushing tag to remote {remote.Name} ...");
|
||||||
new Commands.Push(_repo.FullPath, remote.Name, _tagName, false).Exec();
|
new Commands.Push(_repo.FullPath, remote.Name, $"refs/tags/{_tagName}", false).Exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,14 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
bool succ = true;
|
var succ = true;
|
||||||
|
var tag = $"refs/tags/{Target.Name}";
|
||||||
if (_pushAllRemotes)
|
if (_pushAllRemotes)
|
||||||
{
|
{
|
||||||
foreach (var remote in _repo.Remotes)
|
foreach (var remote in _repo.Remotes)
|
||||||
{
|
{
|
||||||
SetProgressDescription($"Pushing tag to remote {remote.Name} ...");
|
SetProgressDescription($"Pushing tag to remote {remote.Name} ...");
|
||||||
succ = new Commands.Push(_repo.FullPath, remote.Name, Target.Name, false).Exec();
|
succ = new Commands.Push(_repo.FullPath, remote.Name, tag, false).Exec();
|
||||||
if (!succ)
|
if (!succ)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +58,7 @@ namespace SourceGit.ViewModels
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetProgressDescription($"Pushing tag to remote {SelectedRemote.Name} ...");
|
SetProgressDescription($"Pushing tag to remote {SelectedRemote.Name} ...");
|
||||||
succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec();
|
succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, tag, false).Exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue