@@ -203,11 +203,11 @@ public void execute() throws MojoExecutionException, MojoFailureException {
203
203
}
204
204
}
205
205
206
- private String promptBranchName ()
207
- throws MojoFailureException , CommandLineException {
206
+ private String promptBranchName () throws MojoFailureException , CommandLineException {
208
207
// git for-each-ref --format='%(refname:short)' refs/heads/feature/*
209
- final String featureBranches = gitFindBranches (
210
- gitFlowConfig .getFeatureBranchPrefix (), false );
208
+ final String featureBranches = gitFindBranches (gitFlowConfig .getFeatureBranchPrefix (), false );
209
+
210
+ final String currentBranch = gitCurrentBranch ();
211
211
212
212
if (StringUtils .isBlank (featureBranches )) {
213
213
throw new MojoFailureException ("There are no feature branches." );
@@ -216,17 +216,21 @@ private String promptBranchName()
216
216
final String [] branches = featureBranches .split ("\\ r?\\ n" );
217
217
218
218
List <String > numberedList = new ArrayList <String >();
219
+ String defaultChoice = null ;
219
220
StringBuilder str = new StringBuilder ("Feature branches:" ).append (LS );
220
221
for (int i = 0 ; i < branches .length ; i ++) {
221
222
str .append ((i + 1 ) + ". " + branches [i ] + LS );
222
223
numberedList .add (String .valueOf (i + 1 ));
224
+ if (branches [i ].equals (currentBranch )) {
225
+ defaultChoice = String .valueOf (i + 1 );
226
+ }
223
227
}
224
228
str .append ("Choose feature branch to finish" );
225
229
226
230
String featureNumber = null ;
227
231
try {
228
232
while (StringUtils .isBlank (featureNumber )) {
229
- featureNumber = prompter .prompt (str .toString (), numberedList );
233
+ featureNumber = prompter .prompt (str .toString (), numberedList , defaultChoice );
230
234
}
231
235
} catch (PrompterException e ) {
232
236
throw new MojoFailureException ("feature-finish" , e );
0 commit comments