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

@ -119,6 +119,7 @@
<x:String x:Key="Text.CreateTag.Message.Placeholder" xml:space="preserve">Optional.</x:String>
<x:String x:Key="Text.CreateTag.Name" xml:space="preserve">Tag Name :</x:String>
<x:String x:Key="Text.CreateTag.Name.Placeholder" xml:space="preserve">Recommended format v1.0.0-alpha</x:String>
<x:String x:Key="Text.CreateTag.PushToAllRemotes" xml:space="preserve">Push to all remotes after created</x:String>
<x:String x:Key="Text.CreateTag.Type" xml:space="preserve">Kind </x:String>
<x:String x:Key="Text.CreateTag.Type.Annotated" xml:space="preserve">annotated</x:String>
<x:String x:Key="Text.CreateTag.Type.Lightweight" xml:space="preserve">lightweight</x:String>

View file

@ -119,6 +119,7 @@
<x:String x:Key="Text.CreateTag.Message.Placeholder" xml:space="preserve">选填。</x:String>
<x:String x:Key="Text.CreateTag.Name" xml:space="preserve">标签名 </x:String>
<x:String x:Key="Text.CreateTag.Name.Placeholder" xml:space="preserve">推荐格式 v1.0.0-alpha</x:String>
<x:String x:Key="Text.CreateTag.PushToAllRemotes" xml:space="preserve">推送到所有远程仓库</x:String>
<x:String x:Key="Text.CreateTag.Type" xml:space="preserve">类型 </x:String>
<x:String x:Key="Text.CreateTag.Type.Annotated" xml:space="preserve">附注标签</x:String>
<x:String x:Key="Text.CreateTag.Type.Lightweight" xml:space="preserve">轻量标签</x:String>

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();
}

View file

@ -13,7 +13,7 @@
<TextBlock FontSize="18"
Classes="bold"
Text="{DynamicResource Text.CreateTag}"/>
<Grid Margin="0,16,8,0" RowDefinitions="32,32,32,Auto,Auto" ColumnDefinitions="150,*">
<Grid Margin="0,16,8,0" RowDefinitions="32,32,32,Auto,Auto,32" ColumnDefinitions="150,*">
<TextBlock Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
@ -76,10 +76,14 @@
IsVisible="{Binding Annotated}"/>
<CheckBox Grid.Row="4" Grid.Column="1"
Height="32"
Height="32" Margin="0,4,0,0"
Content="{DynamicResource Text.CreateTag.GPGSign}"
IsChecked="{Binding SignTag, Mode=TwoWay}"
IsVisible="{Binding Annotated}"/>
<CheckBox Grid.Row="5" Grid.Column="1"
Content="{DynamicResource Text.CreateTag.PushToAllRemotes}"
IsChecked="{Binding PushToAllRemotes, Mode=TwoWay}"/>
</Grid>
</StackPanel>
</UserControl>