@@ -203,11 +203,11 @@ public void execute() throws MojoExecutionException, MojoFailureException {
203203 }
204204 }
205205
206- private String promptBranchName ()
207- throws MojoFailureException , CommandLineException {
206+ private String promptBranchName () throws MojoFailureException , CommandLineException {
208207 // 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 ();
211211
212212 if (StringUtils .isBlank (featureBranches )) {
213213 throw new MojoFailureException ("There are no feature branches." );
@@ -216,17 +216,21 @@ private String promptBranchName()
216216 final String [] branches = featureBranches .split ("\\ r?\\ n" );
217217
218218 List <String > numberedList = new ArrayList <String >();
219+ String defaultChoice = null ;
219220 StringBuilder str = new StringBuilder ("Feature branches:" ).append (LS );
220221 for (int i = 0 ; i < branches .length ; i ++) {
221222 str .append ((i + 1 ) + ". " + branches [i ] + LS );
222223 numberedList .add (String .valueOf (i + 1 ));
224+ if (branches [i ].equals (currentBranch )) {
225+ defaultChoice = String .valueOf (i + 1 );
226+ }
223227 }
224228 str .append ("Choose feature branch to finish" );
225229
226230 String featureNumber = null ;
227231 try {
228232 while (StringUtils .isBlank (featureNumber )) {
229- featureNumber = prompter .prompt (str .toString (), numberedList );
233+ featureNumber = prompter .prompt (str .toString (), numberedList , defaultChoice );
230234 }
231235 } catch (PrompterException e ) {
232236 throw new MojoFailureException ("feature-finish" , e );
0 commit comments