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

Merge pull request from Rwing/master
This commit is contained in:
leo 2021-05-13 15:43:45 +08:00 committed by Gitee
commit b56279ce6e
5 changed files with 23 additions and 5 deletions

View file

@ -50,16 +50,17 @@ namespace SourceGit.Commands {
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) {
case Models.GitFlowBranchType.Feature:
Args = $"flow feature finish {name}";
Args = $"flow feature finish {option} {name}";
break;
case Models.GitFlowBranchType.Release:
Args = $"flow release finish {name}";
Args = $"flow release finish {option} {name}";
break;
case Models.GitFlowBranchType.Hotfix:
Args = $"flow hotfix finish {name}";
Args = $"flow hotfix finish {option} {name}";
break;
default:
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.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.KeepBranchAfterFinish">Keep branch</sys:String>
<sys:String x:Key="Text.RepoCM.Refresh">Refresh</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.PrefixInvalid">{0}前缀包含非法字符!</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.Bookmark">书签</sys:String>

View file

@ -10,6 +10,7 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="32"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@ -31,5 +32,17 @@
Grid.Row="0" Grid.Column="2"
Margin="4,0,0,0"
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>
</controls:PopupWidget>

View file

@ -46,9 +46,11 @@ namespace SourceGit.Views.Popups {
}
public override Task<bool> Start() {
var keepBranch = chkKeep.IsChecked == true;
return Task.Run(() => {
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);
return true;
});