Skip to content

Commit

Permalink
fix reading buffer running full, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
ilovemilk committed Nov 26, 2020
1 parent a15081d commit bcc47d8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.3.5]
### Fixed
- Fix large process outputs could lead to a timeout in the command runner due to the reading buffer running full and blocking the process.

## [2.3.4]
### Fixed
- Remove debug statements.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gradle 2.1 and higher

```
plugins {
id("io.wusa.semver-git-plugin").version("2.3.4")
id("io.wusa.semver-git-plugin").version("2.3.5")
}
```

Expand All @@ -25,7 +25,7 @@ buildscript {
}
}
dependencies {
classpath 'io.wusa:semver-git-plugin:2.3.4'
classpath 'io.wusa:semver-git-plugin:2.3.5'
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "io.wusa"
version = "2.3.4"
version = "2.3.5"

dependencies {
implementation(kotlin("stdlib-jdk8"))
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/io/wusa/GitCommandRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class GitCommandRunner {
companion object {
fun execute(projectDir: File, args: Array<String>): String {
val process = startGitProcess(args, projectDir)
val output = readProcessOutput(process)
waitForGitProcess(process)
if (processFinishedWithoutErrors(process)) return readProcessOutput(process)
if (processFinishedWithoutErrors(process)) return output

throw GitException("Executing git command failed with " + process.exitValue())
}
Expand Down
40 changes: 40 additions & 0 deletions src/test/kotlin/io/wusa/SemverGitPluginKotlinFunctionalTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -729,4 +729,44 @@ class SemverGitPluginKotlinFunctionalTest : FunctionalBaseTest() {
println(result.output)
Assertions.assertTrue(result.output.contains("Version: 2.0.43-dirty-SNAPSHOT"))
}

@Test
fun `issue-61 large process outputs leads to timeouts`() {
val testProjectDirectory = createTempDir()
val buildFile = File(testProjectDirectory, "build.gradle.kts")
buildFile.writeText("""
import io.wusa.Info
import io.wusa.TagType
plugins {
id("io.wusa.semver-git-plugin")
}
semver {
tagPrefix = ""
tagType = TagType.ANNOTATED
branches {
branch {
regex = ".+"
incrementer = "CONVENTIONAL_COMMITS_INCREMENTER"
formatter = Transformer<Any, Info>{ info:Info -> "${'$'}{info.version.major}.${'$'}{info.version.minor}.${'$'}{info.version.patch}" }
}
}
}
""")
val git = initializeGitWithoutBranchAnnotated(testProjectDirectory, "2.0.42")
for (x in 0..600) {
val dirty = File(testProjectDirectory, "dirty_$x.file")
dirty.writeText("dirty")
}
git.add().addFilepattern(".").call()

val result = gradleRunner
.withProjectDir(testProjectDirectory)
.withArguments("showInfo")
.withPluginClasspath()
.build()
println(result.output)
Assertions.assertTrue(result.output.contains("Version: 2.0.43-dirty-SNAPSHOT"))
}
}

0 comments on commit bcc47d8

Please sign in to comment.