enhance: add an option to push tag to all remotes after created (#141)

This commit is contained in:
leo 2024-05-24 10:47:37 +08:00
parent b556feb3d3
commit c10778c413
5 changed files with 30 additions and 6 deletions

View file

@ -38,6 +38,12 @@ namespace SourceGit.ViewModels
set;
} = false;
public bool PushToAllRemotes
{
get;
set;
} = true;
public CreateTag(Repository repo, Models.Branch branch)
{
_repo = repo;
@ -75,13 +81,23 @@ namespace SourceGit.ViewModels
return Task.Run(() =>
{
var succ = false;
if (_annotated)
Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn, Message, SignTag);
succ = Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn, Message, SignTag);
else
Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn);
succ = Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn);
if (succ && PushToAllRemotes)
{
foreach (var remote in _repo.Remotes)
{
SetProgressDescription($"Pushing tag to remote {remote.Name} ...");
new Commands.Push(_repo.FullPath, remote.Name, _tagName, false).Exec();
}
}
CallUIThread(() => _repo.SetWatcherEnabled(true));
return true;
return succ;
});
}

View file

@ -39,7 +39,7 @@ namespace SourceGit.ViewModels
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
ProgressDescription = $"Pushing tag '{Target.Name}' to remote '{SelectedRemote.Name}' ...";
ProgressDescription = $"Pushing tag ...";
return Task.Run(() =>
{
@ -48,6 +48,7 @@ namespace SourceGit.ViewModels
{
foreach (var remote in _repo.Remotes)
{
SetProgressDescription($"Pushing tag to remote {remote.Name} ...");
succ = new Commands.Push(_repo.FullPath, remote.Name, Target.Name, false).Exec();
if (!succ)
break;
@ -55,6 +56,7 @@ namespace SourceGit.ViewModels
}
else
{
SetProgressDescription($"Pushing tag to remote {SelectedRemote.Name} ...");
succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec();
}