mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 21:24:59 +00:00
enhance: tag creation & pushing (#141)
* supports creating lightweight tags * supports GPG signed tags * add option to push selected tag to all remotes
This commit is contained in:
parent
0dea7ed0e2
commit
b556feb3d3
11 changed files with 122 additions and 42 deletions
|
@ -1,12 +1,16 @@
|
|||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class CreateTag : Popup
|
||||
{
|
||||
public object BasedOn
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[Required(ErrorMessage = "Tag name is required!")]
|
||||
[RegularExpression(@"^[\w\-\.]+$", ErrorMessage = "Bad tag name format!")]
|
||||
[CustomValidation(typeof(CreateTag), nameof(ValidateTagName))]
|
||||
|
@ -22,11 +26,17 @@ namespace SourceGit.ViewModels
|
|||
set;
|
||||
}
|
||||
|
||||
public object BasedOn
|
||||
public bool Annotated
|
||||
{
|
||||
get => _annotated;
|
||||
set => SetProperty(ref _annotated, value);
|
||||
}
|
||||
|
||||
public bool SignTag
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
set;
|
||||
} = false;
|
||||
|
||||
public CreateTag(Repository repo, Models.Branch branch)
|
||||
{
|
||||
|
@ -65,7 +75,11 @@ namespace SourceGit.ViewModels
|
|||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
Commands.Tag.Add(_repo.FullPath, TagName, _basedOn, Message);
|
||||
if (_annotated)
|
||||
Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn, Message, SignTag);
|
||||
else
|
||||
Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn);
|
||||
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return true;
|
||||
});
|
||||
|
@ -73,6 +87,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
private readonly Repository _repo = null;
|
||||
private string _tagName = string.Empty;
|
||||
private bool _annotated = true;
|
||||
private readonly string _basedOn = string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,12 @@ namespace SourceGit.ViewModels
|
|||
set;
|
||||
}
|
||||
|
||||
public bool PushAllRemotes
|
||||
{
|
||||
get => _pushAllRemotes;
|
||||
set => SetProperty(ref _pushAllRemotes, value);
|
||||
}
|
||||
|
||||
public PushTag(Repository repo, Models.Tag target)
|
||||
{
|
||||
_repo = repo;
|
||||
|
@ -37,12 +43,27 @@ namespace SourceGit.ViewModels
|
|||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec();
|
||||
bool succ = true;
|
||||
if (_pushAllRemotes)
|
||||
{
|
||||
foreach (var remote in _repo.Remotes)
|
||||
{
|
||||
succ = new Commands.Push(_repo.FullPath, remote.Name, Target.Name, false).Exec();
|
||||
if (!succ)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec();
|
||||
}
|
||||
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return succ;
|
||||
});
|
||||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
private bool _pushAllRemotes = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue