From 749dceeaa99393b2a4343893fbe334817b33a931 Mon Sep 17 00:00:00 2001 From: Andrew Oberstar Date: Wed, 19 Aug 2015 21:16:51 -0500 Subject: [PATCH] Refactoring of PR-122 Minor refactoring and doc updates as part of merging #122 to fix #121. --- .../gradle/git/release/opinion/Strategies.groovy | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/groovy/org/ajoberstar/gradle/git/release/opinion/Strategies.groovy b/src/main/groovy/org/ajoberstar/gradle/git/release/opinion/Strategies.groovy index 8192a42..7b9152d 100644 --- a/src/main/groovy/org/ajoberstar/gradle/git/release/opinion/Strategies.groovy +++ b/src/main/groovy/org/ajoberstar/gradle/git/release/opinion/Strategies.groovy @@ -130,9 +130,10 @@ final class Strategies { * * */ @@ -147,13 +148,17 @@ final class Strategies { def majorDiff = major - normal.majorVersion def minorDiff = minor - normal.minorVersion - if (minor <= 0 && majorDiff == 1) { + if (majorDiff == 1 && minor <= 0) { + // major is off by one and minor is either 0 or not in the branch name return incrementNormalFromScope(state, ChangeScope.MAJOR) - } else if (minor > 0 && minorDiff == 1) { + } else if (minorDiff == 1 && minor > 0) { + // minor is off by one and specified in the branch name return incrementNormalFromScope(state, ChangeScope.MINOR) - } else if (majorDiff == 0 && minor >= 0 && minorDiff == 0) { + } else if (majorDiff == 0 && minorDiff == 0 && minor >= 0) { + // major and minor match, both are specified in branch name return incrementNormalFromScope(state, ChangeScope.PATCH) } else if (majorDiff == 0 && minor < 0) { + // only major specified in branch name and already matches return state } else { throw new GradleException("Invalid branch (${state.currentBranch.name}) for nearest normal (${normal}).")