Skip to content

Commit c10778c

Browse files
committed
enhance: add an option to push tag to all remotes after created (#141)
1 parent b556feb commit c10778c

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

src/Resources/Locales/en_US.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
<x:String x:Key="Text.CreateTag.Message.Placeholder" xml:space="preserve">Optional.</x:String>
120120
<x:String x:Key="Text.CreateTag.Name" xml:space="preserve">Tag Name :</x:String>
121121
<x:String x:Key="Text.CreateTag.Name.Placeholder" xml:space="preserve">Recommended format :v1.0.0-alpha</x:String>
122+
<x:String x:Key="Text.CreateTag.PushToAllRemotes" xml:space="preserve">Push to all remotes after created</x:String>
122123
<x:String x:Key="Text.CreateTag.Type" xml:space="preserve">Kind :</x:String>
123124
<x:String x:Key="Text.CreateTag.Type.Annotated" xml:space="preserve">annotated</x:String>
124125
<x:String x:Key="Text.CreateTag.Type.Lightweight" xml:space="preserve">lightweight</x:String>

src/Resources/Locales/zh_CN.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
<x:String x:Key="Text.CreateTag.Message.Placeholder" xml:space="preserve">选填。</x:String>
120120
<x:String x:Key="Text.CreateTag.Name" xml:space="preserve">标签名 :</x:String>
121121
<x:String x:Key="Text.CreateTag.Name.Placeholder" xml:space="preserve">推荐格式 :v1.0.0-alpha</x:String>
122+
<x:String x:Key="Text.CreateTag.PushToAllRemotes" xml:space="preserve">推送到所有远程仓库</x:String>
122123
<x:String x:Key="Text.CreateTag.Type" xml:space="preserve">类型 :</x:String>
123124
<x:String x:Key="Text.CreateTag.Type.Annotated" xml:space="preserve">附注标签</x:String>
124125
<x:String x:Key="Text.CreateTag.Type.Lightweight" xml:space="preserve">轻量标签</x:String>

src/ViewModels/CreateTag.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ public bool SignTag
3838
set;
3939
} = false;
4040

41+
public bool PushToAllRemotes
42+
{
43+
get;
44+
set;
45+
} = true;
46+
4147
public CreateTag(Repository repo, Models.Branch branch)
4248
{
4349
_repo = repo;
@@ -75,13 +81,23 @@ public override Task<bool> Sure()
7581

7682
return Task.Run(() =>
7783
{
84+
var succ = false;
7885
if (_annotated)
79-
Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn, Message, SignTag);
86+
succ = Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn, Message, SignTag);
8087
else
81-
Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn);
88+
succ = Commands.Tag.Add(_repo.FullPath, _tagName, _basedOn);
89+
90+
if (succ && PushToAllRemotes)
91+
{
92+
foreach (var remote in _repo.Remotes)
93+
{
94+
SetProgressDescription($"Pushing tag to remote {remote.Name} ...");
95+
new Commands.Push(_repo.FullPath, remote.Name, _tagName, false).Exec();
96+
}
97+
}
8298

8399
CallUIThread(() => _repo.SetWatcherEnabled(true));
84-
return true;
100+
return succ;
85101
});
86102
}
87103

src/ViewModels/PushTag.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public PushTag(Repository repo, Models.Tag target)
3939
public override Task<bool> Sure()
4040
{
4141
_repo.SetWatcherEnabled(false);
42-
ProgressDescription = $"Pushing tag '{Target.Name}' to remote '{SelectedRemote.Name}' ...";
42+
ProgressDescription = $"Pushing tag ...";
4343

4444
return Task.Run(() =>
4545
{
@@ -48,13 +48,15 @@ public override Task<bool> Sure()
4848
{
4949
foreach (var remote in _repo.Remotes)
5050
{
51+
SetProgressDescription($"Pushing tag to remote {remote.Name} ...");
5152
succ = new Commands.Push(_repo.FullPath, remote.Name, Target.Name, false).Exec();
5253
if (!succ)
5354
break;
5455
}
5556
}
5657
else
5758
{
59+
SetProgressDescription($"Pushing tag to remote {SelectedRemote.Name} ...");
5860
succ = new Commands.Push(_repo.FullPath, SelectedRemote.Name, Target.Name, false).Exec();
5961
}
6062

src/Views/CreateTag.axaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<TextBlock FontSize="18"
1414
Classes="bold"
1515
Text="{DynamicResource Text.CreateTag}"/>
16-
<Grid Margin="0,16,8,0" RowDefinitions="32,32,32,Auto,Auto" ColumnDefinitions="150,*">
16+
<Grid Margin="0,16,8,0" RowDefinitions="32,32,32,Auto,Auto,32" ColumnDefinitions="150,*">
1717
<TextBlock Grid.Column="0"
1818
HorizontalAlignment="Right" VerticalAlignment="Center"
1919
Margin="0,0,8,0"
@@ -76,10 +76,14 @@
7676
IsVisible="{Binding Annotated}"/>
7777

7878
<CheckBox Grid.Row="4" Grid.Column="1"
79-
Height="32"
79+
Height="32" Margin="0,4,0,0"
8080
Content="{DynamicResource Text.CreateTag.GPGSign}"
8181
IsChecked="{Binding SignTag, Mode=TwoWay}"
8282
IsVisible="{Binding Annotated}"/>
83+
84+
<CheckBox Grid.Row="5" Grid.Column="1"
85+
Content="{DynamicResource Text.CreateTag.PushToAllRemotes}"
86+
IsChecked="{Binding PushToAllRemotes, Mode=TwoWay}"/>
8387
</Grid>
8488
</StackPanel>
8589
</UserControl>

0 commit comments

Comments
 (0)