feature<GitFlow>: add an option to keep branch after finish

This commit is contained in:
Rwing 2021-05-13 15:31:10 +08:00
parent 524eb8ef6d
commit 0f38b157e2
5 changed files with 23 additions and 5 deletions

View file

@ -50,16 +50,17 @@ namespace SourceGit.Commands {
Exec(); Exec();
} }
public void Finish(Models.GitFlowBranchType type, string name) { public void Finish(Models.GitFlowBranchType type, string name, bool keepBranch) {
var option = keepBranch ? "-k" : string.Empty;
switch (type) { switch (type) {
case Models.GitFlowBranchType.Feature: case Models.GitFlowBranchType.Feature:
Args = $"flow feature finish {name}"; Args = $"flow feature finish {option} {name}";
break; break;
case Models.GitFlowBranchType.Release: case Models.GitFlowBranchType.Release:
Args = $"flow release finish {name}"; Args = $"flow release finish {option} {name}";
break; break;
case Models.GitFlowBranchType.Hotfix: case Models.GitFlowBranchType.Hotfix:
Args = $"flow hotfix finish {name}"; Args = $"flow hotfix finish {option} {name}";
break; break;
default: default:
return; return;

View file

@ -151,6 +151,7 @@
<sys:String x:Key="Text.GitFlow.PrefixRequired">{0} prefix is required.</sys:String> <sys:String x:Key="Text.GitFlow.PrefixRequired">{0} prefix is required.</sys:String>
<sys:String x:Key="Text.GitFlow.PrefixInvalid">{0} contains invalid characters.</sys:String> <sys:String x:Key="Text.GitFlow.PrefixInvalid">{0} contains invalid characters.</sys:String>
<sys:String x:Key="Text.GitFlow.DevSameAsProd">Development branch is same with production!</sys:String> <sys:String x:Key="Text.GitFlow.DevSameAsProd">Development branch is same with production!</sys:String>
<sys:String x:Key="Text.GitFlow.KeepBranchAfterFinish">Keep branch</sys:String>
<sys:String x:Key="Text.RepoCM.Refresh">Refresh</sys:String> <sys:String x:Key="Text.RepoCM.Refresh">Refresh</sys:String>
<sys:String x:Key="Text.RepoCM.Bookmark">Bookmark</sys:String> <sys:String x:Key="Text.RepoCM.Bookmark">Bookmark</sys:String>

View file

@ -151,6 +151,7 @@
<sys:String x:Key="Text.GitFlow.PrefixRequired">{0}前缀未填写!</sys:String> <sys:String x:Key="Text.GitFlow.PrefixRequired">{0}前缀未填写!</sys:String>
<sys:String x:Key="Text.GitFlow.PrefixInvalid">{0}前缀包含非法字符!</sys:String> <sys:String x:Key="Text.GitFlow.PrefixInvalid">{0}前缀包含非法字符!</sys:String>
<sys:String x:Key="Text.GitFlow.DevSameAsProd">开发分支与发布分支不可相同!</sys:String> <sys:String x:Key="Text.GitFlow.DevSameAsProd">开发分支与发布分支不可相同!</sys:String>
<sys:String x:Key="Text.GitFlow.KeepBranchAfterFinish">保留分支</sys:String>
<sys:String x:Key="Text.RepoCM.Refresh">刷新</sys:String> <sys:String x:Key="Text.RepoCM.Refresh">刷新</sys:String>
<sys:String x:Key="Text.RepoCM.Bookmark">书签</sys:String> <sys:String x:Key="Text.RepoCM.Bookmark">书签</sys:String>

View file

@ -10,6 +10,7 @@
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="32"/> <RowDefinition Height="32"/>
<RowDefinition Height="32"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -31,5 +32,17 @@
Grid.Row="0" Grid.Column="2" Grid.Row="0" Grid.Column="2"
Margin="4,0,0,0" Margin="4,0,0,0"
x:Name="txtName"/> x:Name="txtName"/>
<TextBlock
Grid.Row="1" Grid.Column="0"
Margin="0,0,8,0"
x:Name="txtKeep"
HorizontalAlignment="Right"
Text="{StaticResource Text.GitFlow.KeepBranchAfterFinish}"/>
<CheckBox
Grid.Row="1" Grid.Column="2"
Margin="0,4,0,0"
x:Name="chkKeep"
IsChecked="False"
/>
</Grid> </Grid>
</controls:PopupWidget> </controls:PopupWidget>

View file

@ -46,9 +46,11 @@ namespace SourceGit.Views.Popups {
} }
public override Task<bool> Start() { public override Task<bool> Start() {
var keepBranch = chkKeep.IsChecked == true;
return Task.Run(() => { return Task.Run(() => {
Models.Watcher.SetEnabled(repo, false); Models.Watcher.SetEnabled(repo, false);
new Commands.GitFlow(repo).Finish(type, name); new Commands.GitFlow(repo).Finish(type, name, keepBranch);
Models.Watcher.SetEnabled(repo, true); Models.Watcher.SetEnabled(repo, true);
return true; return true;
}); });