18
18
import java .text .DateFormat ;
19
19
import java .text .SimpleDateFormat ;
20
20
import java .util .ArrayList ;
21
+ import java .util .Arrays ;
22
+ import java .util .Collections ;
21
23
import java .util .Date ;
22
24
import java .util .List ;
23
25
import java .util .Map ;
@@ -75,6 +77,14 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
75
77
@ Parameter (defaultValue = "${gitFlowConfig}" )
76
78
protected GitFlowConfig gitFlowConfig ;
77
79
80
+ /**
81
+ * Whether to use --atomic option on push.
82
+ *
83
+ * @since 1.6.1
84
+ */
85
+ @ Parameter (property = "verbose" , defaultValue = "false" )
86
+ private boolean atomicPush = false ;
87
+
78
88
/**
79
89
* Git commit messages.
80
90
*
@@ -93,7 +103,7 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
93
103
94
104
/**
95
105
* Whether to call Maven install goal during the mojo execution.
96
- *
106
+ *
97
107
* @since 1.0.5
98
108
*/
99
109
@ Parameter (property = "installProject" , defaultValue = "false" )
@@ -190,6 +200,8 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
190
200
@ Parameter (defaultValue = "${settings}" , readonly = true )
191
201
protected Settings settings ;
192
202
203
+
204
+
193
205
/**
194
206
* Initializes command line executables.
195
207
*
@@ -965,28 +977,31 @@ private boolean gitFetchRemote(final String branchName)
965
977
/**
966
978
* Executes git push, optionally with the <code>--follow-tags</code>
967
979
* argument.
968
- *
969
- * @param branchName
970
- * Branch name to push.
980
+ *
981
+ * @param branchNames
982
+ * Branch names to push. Names proceeded by : will be deleted
971
983
* @param pushTags
972
984
* If <code>true</code> adds <code>--follow-tags</code> argument
973
985
* to the git <code>push</code> command.
974
986
* @throws MojoFailureException
975
987
* @throws CommandLineException
976
988
*/
977
- protected void gitPush (final String branchName , boolean pushTags )
989
+ protected void gitPush (boolean pushTags , final String ... branchNames )
978
990
throws MojoFailureException , CommandLineException {
979
991
getLog ().info (
980
- "Pushing '" + branchName + "' branch" + " to '"
992
+ "Pushing '" + Arrays . toString ( branchNames ) + "' branch" + " to '"
981
993
+ gitFlowConfig .getOrigin () + "'." );
982
994
995
+ List <String > argsList = Arrays .asList ("push" , "--quiet" , "-u" , gitFlowConfig .getOrigin ());
996
+ if (atomicPush ){
997
+ argsList .add ("--atomic" );
998
+ }
999
+ Collections .addAll (argsList , branchNames );
983
1000
if (pushTags ) {
984
- executeGitCommand ("push" , "--quiet" , "-u" , "--follow-tags" ,
985
- gitFlowConfig .getOrigin (), branchName );
986
- } else {
987
- executeGitCommand ("push" , "--quiet" , "-u" ,
988
- gitFlowConfig .getOrigin (), branchName );
1001
+ argsList .add ("--follow-tags" );
989
1002
}
1003
+ String [] argsArray = argsList .toArray (new String [0 ]);
1004
+ executeGitCommand (argsArray );
990
1005
}
991
1006
992
1007
protected void gitPushDelete (final String branchName )
0 commit comments