Skip to content

Commit 340754c

Browse files
committed
Change some code style
1 parent e8b4c6d commit 340754c

File tree

2 files changed

+32
-67
lines changed

2 files changed

+32
-67
lines changed

src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Map;
2626
import java.util.Map.Entry;
2727
import java.util.NoSuchElementException;
28-
import java.util.Objects;
2928
import java.util.Set;
3029
import java.util.TimeZone;
3130
import java.util.regex.Pattern;
@@ -417,8 +416,7 @@ protected void checkSnapshotDependencies() throws MojoFailureException {
417416
*/
418417
protected boolean validBranchName(final String branchName)
419418
throws MojoFailureException, CommandLineException {
420-
CommandResult res = executeGitCommandExitCode("check-ref-format",
421-
"--allow-onelevel", branchName);
419+
CommandResult res = executeGitCommandExitCode("check-ref-format", "--allow-onelevel", branchName);
422420
return res.getExitCode() == SUCCESS_EXIT_CODE;
423421
}
424422

@@ -440,16 +438,14 @@ private boolean executeGitHasUncommitted() throws MojoFailureException,
440438

441439
// git diff --no-ext-diff --ignore-submodules --quiet --exit-code
442440
final CommandResult diffCommandResult = executeGitCommandExitCode(
443-
"diff", "--no-ext-diff", "--ignore-submodules", "--quiet",
444-
"--exit-code");
441+
"diff", "--no-ext-diff", "--ignore-submodules", "--quiet", "--exit-code");
445442

446443
String error = null;
447444

448445
if (diffCommandResult.getExitCode() == SUCCESS_EXIT_CODE) {
449446
// git diff-index --cached --quiet --ignore-submodules HEAD --
450447
final CommandResult diffIndexCommandResult = executeGitCommandExitCode(
451-
"diff-index", "--cached", "--quiet", "--ignore-submodules",
452-
"HEAD", "--");
448+
"diff-index", "--cached", "--quiet", "--ignore-submodules", "HEAD", "--");
453449
if (diffIndexCommandResult.getExitCode() != SUCCESS_EXIT_CODE) {
454450
error = diffIndexCommandResult.getError();
455451
uncommited = true;
@@ -476,21 +472,14 @@ private boolean executeGitHasUncommitted() throws MojoFailureException,
476472
*/
477473
protected void initGitFlowConfig() throws MojoFailureException,
478474
CommandLineException {
479-
gitSetConfig("gitflow.branch.master",
480-
gitFlowConfig.getProductionBranch());
481-
gitSetConfig("gitflow.branch.develop",
482-
gitFlowConfig.getDevelopmentBranch());
475+
gitSetConfig("gitflow.branch.master", gitFlowConfig.getProductionBranch());
476+
gitSetConfig("gitflow.branch.develop", gitFlowConfig.getDevelopmentBranch());
483477

484-
gitSetConfig("gitflow.prefix.feature",
485-
gitFlowConfig.getFeatureBranchPrefix());
486-
gitSetConfig("gitflow.prefix.release",
487-
gitFlowConfig.getReleaseBranchPrefix());
488-
gitSetConfig("gitflow.prefix.hotfix",
489-
gitFlowConfig.getHotfixBranchPrefix());
490-
gitSetConfig("gitflow.prefix.support",
491-
gitFlowConfig.getSupportBranchPrefix());
492-
gitSetConfig("gitflow.prefix.versiontag",
493-
gitFlowConfig.getVersionTagPrefix());
478+
gitSetConfig("gitflow.prefix.feature", gitFlowConfig.getFeatureBranchPrefix());
479+
gitSetConfig("gitflow.prefix.release", gitFlowConfig.getReleaseBranchPrefix());
480+
gitSetConfig("gitflow.prefix.hotfix", gitFlowConfig.getHotfixBranchPrefix());
481+
gitSetConfig("gitflow.prefix.support", gitFlowConfig.getSupportBranchPrefix());
482+
gitSetConfig("gitflow.prefix.versiontag", gitFlowConfig.getVersionTagPrefix());
494483

495484
gitSetConfig("gitflow.origin", gitFlowConfig.getOrigin());
496485
}
@@ -651,8 +640,7 @@ protected String gitCurrentBranch() throws MojoFailureException, CommandLineExce
651640
*/
652641
protected boolean gitCheckBranchExists(final String branchName)
653642
throws MojoFailureException, CommandLineException {
654-
CommandResult commandResult = executeGitCommandExitCode("show-ref",
655-
"--verify", "--quiet", "refs/heads/" + branchName);
643+
CommandResult commandResult = executeGitCommandExitCode("show-ref", "--verify", "--quiet", "refs/heads/" + branchName);
656644
return commandResult.getExitCode() == SUCCESS_EXIT_CODE;
657645
}
658646

@@ -668,8 +656,7 @@ protected boolean gitCheckBranchExists(final String branchName)
668656
* If command line execution fails.
669657
*/
670658
protected boolean gitCheckTagExists(final String tagName) throws MojoFailureException, CommandLineException {
671-
CommandResult commandResult = executeGitCommandExitCode("show-ref", "--verify", "--quiet",
672-
"refs/tags/" + tagName);
659+
CommandResult commandResult = executeGitCommandExitCode("show-ref", "--verify", "--quiet", "refs/tags/" + tagName);
673660
return commandResult.getExitCode() == SUCCESS_EXIT_CODE;
674661
}
675662

@@ -706,8 +693,7 @@ protected void gitCreateAndCheckout(final String newBranchName,
706693
final String fromBranchName) throws MojoFailureException,
707694
CommandLineException {
708695
getLog().info(
709-
"Creating a new branch '" + newBranchName + "' from '"
710-
+ fromBranchName + "' and checking it out.");
696+
"Creating a new branch '" + newBranchName + "' from '" + fromBranchName + "' and checking it out.");
711697

712698
executeGitCommand("checkout", "-b", newBranchName, fromBranchName);
713699
}
@@ -727,8 +713,7 @@ protected void gitCreateAndCheckout(final String newBranchName,
727713
protected void gitCreateBranch(final String newBranchName, final String fromBranchName)
728714
throws MojoFailureException, CommandLineException {
729715
getLog().info(
730-
"Creating a new branch '" + newBranchName + "' from '"
731-
+ fromBranchName + "'.");
716+
"Creating a new branch '" + newBranchName + "' from '" + fromBranchName + "'.");
732717

733718
executeGitCommand("branch", newBranchName, fromBranchName);
734719
}
@@ -761,8 +746,7 @@ private String replaceProperties(String message, Map<String, String> map) {
761746
* @throws CommandLineException
762747
* If command line execution fails.
763748
*/
764-
protected void gitCommit(final String message) throws MojoFailureException,
765-
CommandLineException {
749+
protected void gitCommit(final String message) throws MojoFailureException, CommandLineException {
766750
gitCommit(message, null);
767751
}
768752

@@ -970,8 +954,7 @@ protected void gitFetchRemoteAndCreate(final String branchName)
970954
+ "' doesn't exist. Trying to fetch and check it out from '"
971955
+ gitFlowConfig.getOrigin() + "'.");
972956
gitFetchRemote(branchName);
973-
gitCreateAndCheckout(branchName, gitFlowConfig.getOrigin() + "/"
974-
+ branchName);
957+
gitCreateAndCheckout(branchName, gitFlowConfig.getOrigin() + "/" + branchName);
975958
}
976959
}
977960

@@ -1053,14 +1036,11 @@ private boolean gitFetchRemote() throws MojoFailureException, CommandLineExcepti
10531036
* @throws CommandLineException
10541037
* If command line execution fails.
10551038
*/
1056-
private boolean gitFetchRemote(final String branchName)
1057-
throws MojoFailureException, CommandLineException {
1039+
private boolean gitFetchRemote(final String branchName) throws MojoFailureException, CommandLineException {
10581040
getLog().info(
1059-
"Fetching remote branch '" + gitFlowConfig.getOrigin() + " "
1060-
+ branchName + "'.");
1041+
"Fetching remote branch '" + gitFlowConfig.getOrigin() + " " + branchName + "'.");
10611042

1062-
CommandResult result = executeGitCommandExitCode("fetch", "--quiet",
1063-
gitFlowConfig.getOrigin(), branchName);
1043+
CommandResult result = executeGitCommandExitCode("fetch", "--quiet", gitFlowConfig.getOrigin(), branchName);
10641044

10651045
boolean success = result.getExitCode() == SUCCESS_EXIT_CODE;
10661046
if (!success) {
@@ -1120,17 +1100,14 @@ protected void gitPush(final String branchName, boolean pushTags) throws MojoFai
11201100
protected void gitPushDelete(final String branchName)
11211101
throws MojoFailureException, CommandLineException {
11221102
getLog().info(
1123-
"Deleting remote branch '" + branchName + "' from '"
1124-
+ gitFlowConfig.getOrigin() + "'.");
1103+
"Deleting remote branch '" + branchName + "' from '" + gitFlowConfig.getOrigin() + "'.");
11251104

1126-
CommandResult result = executeGitCommandExitCode("push", "--delete",
1127-
gitFlowConfig.getOrigin(), branchName);
1105+
CommandResult result = executeGitCommandExitCode("push", "--delete", gitFlowConfig.getOrigin(), branchName);
11281106

11291107
if (result.getExitCode() != SUCCESS_EXIT_CODE) {
11301108
getLog().warn(
11311109
"There were some problems deleting remote branch '"
1132-
+ branchName + "' from '"
1133-
+ gitFlowConfig.getOrigin() + "'.");
1110+
+ branchName + "' from '" + gitFlowConfig.getOrigin() + "'.");
11341111
}
11351112
}
11361113

src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowHotfixStartMojo.java

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
147147
}
148148
}
149149

150-
// need to be in master to get correct project version
151-
// git checkout master
150+
// need to be in the correct branch to get correct project version
152151
gitCheckout(branchName);
153152

154153
// fetch and check remote
@@ -164,21 +163,16 @@ public void execute() throws MojoExecutionException, MojoFailureException {
164163
hotfixVersionDigitToIncrement);
165164

166165
if (defaultVersion == null) {
167-
throw new MojoFailureException(
168-
"Cannot get default project version.");
166+
throw new MojoFailureException("Cannot get default next version.");
169167
}
170168

171169
String version = null;
172170
if (settings.isInteractiveMode()) {
173171
try {
174172
while (version == null) {
175-
version = prompter
176-
.prompt("What is the hotfix version? ["
177-
+ defaultVersion + "]");
173+
version = prompter.prompt("What is the hotfix version? [" + defaultVersion + "]");
178174

179-
if (!"".equals(version)
180-
&& (!GitFlowVersionInfo.isValidVersion(version)
181-
|| !validBranchName(version))) {
175+
if (!"".equals(version) && (!GitFlowVersionInfo.isValidVersion(version) || !validBranchName(version))) {
182176
getLog().info("The version is not valid.");
183177
version = null;
184178
}
@@ -188,10 +182,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
188182
}
189183
} else {
190184
if (StringUtils.isNotBlank(hotfixVersion)
191-
&& (!GitFlowVersionInfo.isValidVersion(hotfixVersion)
192-
|| !validBranchName(hotfixVersion))) {
193-
throw new MojoFailureException("The hotfix version '"
194-
+ hotfixVersion + "' is not valid.");
185+
&& (!GitFlowVersionInfo.isValidVersion(hotfixVersion) || !validBranchName(hotfixVersion))) {
186+
throw new MojoFailureException("The hotfix version '" + hotfixVersion + "' is not valid.");
195187
} else {
196188
version = hotfixVersion;
197189
}
@@ -205,20 +197,16 @@ public void execute() throws MojoExecutionException, MojoFailureException {
205197
// to finish hotfix on support branch
206198
String branchVersionPart = version.replace('/', '_');
207199

208-
String hotfixBranchName = gitFlowConfig.getHotfixBranchPrefix()
209-
+ branchVersionPart;
200+
String hotfixBranchName = gitFlowConfig.getHotfixBranchPrefix() + branchVersionPart;
210201
if (!gitFlowConfig.getProductionBranch().equals(branchName)) {
211-
hotfixBranchName = gitFlowConfig.getHotfixBranchPrefix()
212-
+ branchName + "/" + branchVersionPart;
202+
hotfixBranchName = gitFlowConfig.getHotfixBranchPrefix() + branchName + "/" + branchVersionPart;
213203
}
214204

215205
// git for-each-ref refs/heads/hotfix/...
216-
final boolean hotfixBranchExists = gitCheckBranchExists(
217-
hotfixBranchName);
206+
final boolean hotfixBranchExists = gitCheckBranchExists(hotfixBranchName);
218207

219208
if (hotfixBranchExists) {
220-
throw new MojoFailureException(
221-
"Hotfix branch with that name already exists. Cannot start hotfix.");
209+
throw new MojoFailureException("Hotfix branch with that name already exists. Cannot start hotfix.");
222210
}
223211

224212
// git checkout -b hotfix/... master

0 commit comments

Comments
 (0)