Skip to content

Commit

Permalink
Merge pull request #181 from ajoberstar/bump
Browse files Browse the repository at this point in the history
major: Allow incrementing by higher scope than requested
  • Loading branch information
ajoberstar committed Aug 14, 2022
2 parents fc071b2 + 9152df5 commit b85f526
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 57 deletions.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
2 changes: 1 addition & 1 deletion reckon-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description = "Infer a project's version from your Git repository."

mavenCentral {
developerName.set("Andrew Oberstar")
developerEmail.set("ajoberstar@gmail.com")
developerEmail.set("andrew@ajoberstar.org")
githubOwner.set("ajoberstar")
githubRepository.set("reckon")
}
Expand Down
23 changes: 12 additions & 11 deletions reckon-core/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
# This file is expected to be part of source control.
com.github.zafarkhaja:java-semver:0.9.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.googlecode.javaewah:JavaEWAH:1.1.13=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy-agent:1.12.7=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.12.7=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy-agent:1.12.13=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.12.13=testCompileClasspath,testRuntimeClasspath
org.ajoberstar.grgit:grgit-core:5.0.0=testCompileClasspath,testRuntimeClasspath
org.apache.commons:commons-lang3:3.12.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.codehaus.groovy:groovy:3.0.9=testCompileClasspath,testRuntimeClasspath
org.eclipse.jgit:org.eclipse.jgit:6.0.0.202111291000-r=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.8.2=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-engine:5.8.2=testRuntimeClasspath
org.junit.jupiter:junit-jupiter-params:5.8.2=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter:5.8.2=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.8.2=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.8.2=testRuntimeClasspath
org.junit:junit-bom:5.8.2=testCompileClasspath,testRuntimeClasspath
org.mockito:mockito-core:4.3.1=testCompileClasspath,testRuntimeClasspath
org.eclipse.jgit:org.eclipse.jgit:6.0.0.202111291000-r=testCompileClasspath,testRuntimeClasspath
org.eclipse.jgit:org.eclipse.jgit:6.2.0.202206071550-r=compileClasspath,runtimeClasspath
org.junit.jupiter:junit-jupiter-api:5.9.0=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-engine:5.9.0=testRuntimeClasspath
org.junit.jupiter:junit-jupiter-params:5.9.0=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter:5.9.0=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.9.0=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.9.0=testRuntimeClasspath
org.junit:junit-bom:5.9.0=testCompileClasspath,testRuntimeClasspath
org.mockito:mockito-core:4.7.0=testCompileClasspath,testRuntimeClasspath
org.objenesis:objenesis:3.2=testRuntimeClasspath
org.opentest4j:opentest4j:1.2.0=testCompileClasspath,testRuntimeClasspath
org.slf4j:slf4j-api:1.7.30=compileClasspath,runtimeClasspath,testCompileClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,16 @@ private Version reckonNormal(VcsInventory inventory) {

// if a version's already being developed on a parallel branch we'll skip it
if (inventory.getParallelNormals().contains(targetNormal)) {
logger.debug("Skipping {} as it's being developed on a parallel branch. Incrementing again with {}", targetNormal, scope);
targetNormal = targetNormal.incrementNormal(scope);
}

// if it's still in parallel, increment with higher scope

if (inventory.getParallelNormals().contains(targetNormal) && scope != Scope.MAJOR) {
// TODO maybe only do this for "soft" scopes (i.e. not explicitly asked for)
logger.debug("Skipping {} as it's being developed on a parallel branch. Incrementing again with {}", targetNormal, scope);
targetNormal = targetNormal.incrementNormal(scope.increment());
}

return targetNormal;
Expand Down
13 changes: 13 additions & 0 deletions reckon-core/src/main/java/org/ajoberstar/reckon/core/Scope.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ public enum Scope {
// always keep these in ascending order of significance
PATCH, MINOR, MAJOR;

public Scope increment() {
switch (this) {
case MAJOR:
throw new IllegalStateException("Cannot increment MAJOR");
case MINOR:
return MAJOR;
case PATCH:
return MINOR;
default:
throw new AssertionError("Invalid scope: " + this);
}
}

/**
* Parses a String version of a Scope. This is an alternative to {@code valueOf} which only supports
* literal matches. This method supports mixed case String representations, like Major or minor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,6 @@ public void rebuildOnParallel() throws IOException {
assertEquals("0.1.0", reckonStage(null, null));
}

@Disabled("This is't working")
@Test
@DisplayName("multiple release branches")
public void multipleReleaseBranches() throws IOException {
commit();
branch("release/2.0.x");
checkout("release/2.0.x");
commit();
tag("2.0.0");
commit();
tag("2.0.1");
checkout("2.0.0");
branch("release/2.1.x");
checkout("release/2.1.x");
commit();
checkout("2.0.0");
branch("release/3.0.x");
checkout("release/3.0.x");
commit();
tag("3.0.0-dev.0");
commit();
tag("3.0.0-rc.1");
checkout("2.0.0");
branch("release/3.1.x");
checkout("release/3.1.x");
commit();
tag("3.1.0-dev.0");
commit();

assertEquals("3.1.0-dev.1.1+" + TIMESTAMP, reckonStage(null, null));
}

@BeforeEach
public void setupRepo() throws IOException {
repoDir = Files.createTempDirectory("repo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,22 @@ public void conflictingParallelDoubleIncrements() {
assertEquals("3.0.0", reckonStage(inventory, Scope.MAJOR, "final"));
}

@Test
@DisplayName("if incremented via paralel still in parallel, increment with higher scope")
public void doubleConflictingParallelIncrementsHigherScope() {
var inventory = new VcsInventory(
"abcdef",
true,
null,
Version.valueOf("1.1.0"),
Version.valueOf("1.1.0"),
1,
Set.of(Version.valueOf("1.1.1"), Version.valueOf("1.1.2")),
Set.of(Version.valueOf("1.1.0"), Version.valueOf("1.1.1"), Version.valueOf("1.1.2")),
List.of());
assertEquals("1.2.0", reckonStage(inventory, Scope.PATCH, "final"));
}

@Test
@DisplayName("if target normal is in the claimed versions, throw")
public void claimedTargetThrows() {
Expand Down
2 changes: 1 addition & 1 deletion reckon-gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "Infer a project's version from your Git repository."

mavenCentral {
developerName.set("Andrew Oberstar")
developerEmail.set("ajoberstar@gmail.com")
developerEmail.set("andrew@ajoberstar.org")
githubOwner.set("ajoberstar")
githubRepository.set("reckon")
}
Expand Down
4 changes: 2 additions & 2 deletions reckon-gradle/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
cglib:cglib-nodep:3.3.0=compatTestCompileClasspath,compatTestRuntimeClasspath
com.github.zafarkhaja:java-semver:0.9.0=runtimeClasspath,testRuntimeClasspath
com.google.code.findbugs:jsr305:3.0.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.7.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.11.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.guava:failureaccess:1.0.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.guava:guava:31.0.1-jre=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.guava:guava:31.1-jre=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.j2objc:j2objc-annotations:1.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.googlecode.javaewah:JavaEWAH:1.1.13=compatTestCompileClasspath,compatTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand Down
4 changes: 2 additions & 2 deletions reckon-gradle/stutter.lockfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# DO NOT MODIFY: Generated by Stutter plugin.
java11=7.0.2,7.4
java17=7.3.3,7.4
java11=7.0.2,7.5.1
java17=7.3.3,7.5.1
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pluginManagement {
id("org.ajoberstar.reckon") version "0.16.1"
id("org.ajoberstar.stutter") version "0.7.1"

id("com.diffplug.spotless") version "6.3.0"
id("com.diffplug.spotless") version "6.9.1"
}

repositories {
Expand Down

0 comments on commit b85f526

Please sign in to comment.