├── settings.gradle ├── .gitignore ├── src ├── test │ ├── resources │ │ ├── malformed │ │ │ ├── both │ │ │ │ ├── notesConfig.yml │ │ │ │ └── notesConfig.json │ │ │ ├── yml │ │ │ │ └── notesConfig.yml │ │ │ └── json │ │ │ │ └── notesConfig.json │ │ ├── normal │ │ │ ├── both │ │ │ │ ├── notesConfig.yml │ │ │ │ └── notesConfig.json │ │ │ ├── yml │ │ │ │ └── notesConfig.yml │ │ │ └── json │ │ │ │ └── notesConfig.json │ │ ├── output │ │ │ └── output.txt │ │ └── git-log │ │ │ └── git-log.txt │ └── kotlin │ │ └── com │ │ └── micbakos │ │ └── releasenotes │ │ ├── utilities │ │ └── SystemErrorStub.kt │ │ ├── providers │ │ ├── ArgumentsProvider.kt │ │ ├── PullRequestProvider.kt │ │ └── ConfigProvider.kt │ │ ├── ReporterTest.kt │ │ ├── PullRequestResolverTest.kt │ │ ├── ArgumentsReaderTest.kt │ │ └── EnvironmentConfigTest.kt └── main │ └── kotlin │ └── com │ └── micbakos │ └── releasenotes │ ├── Writer.kt │ ├── Notes.kt │ ├── ArgumentsReader.kt │ ├── EnvironmentConfig.kt │ ├── GitLogger.kt │ ├── Models.kt │ └── PullRequestResolver.kt ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── notes ├── .github └── workflows │ └── quality.yml ├── LICENSE.txt ├── gradlew.bat ├── README.md └── gradlew /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "notes" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .gradle/ 3 | build/ 4 | out/ 5 | *.iml 6 | -------------------------------------------------------------------------------- /src/test/resources/malformed/both/notesConfig.yml: -------------------------------------------------------------------------------- 1 | whatever: 2 | - content: -------------------------------------------------------------------------------- /src/test/resources/malformed/yml/notesConfig.yml: -------------------------------------------------------------------------------- 1 | whatever: 2 | - content: -------------------------------------------------------------------------------- /src/test/resources/malformed/both/notesConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "whatever": "content" 3 | } -------------------------------------------------------------------------------- /src/test/resources/malformed/json/notesConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "whatever": "content" 3 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micbakos/ReleaseNotes/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /notes: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Resolve directory of the script 4 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 5 | 6 | # Run the project 7 | "$DIR"/gradlew -b "$DIR"/build.gradle run -q --args="$1 $2 $3 $4 $5" 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Feb 28 17:53:28 EET 2020 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /src/test/resources/normal/both/notesConfig.yml: -------------------------------------------------------------------------------- 1 | variants: 2 | - name: project 3 | categories: 4 | - title: Features 5 | regex: feature\/.+ 6 | - title: Bugs 7 | regex: bug\/.+ 8 | links: 9 | - url: https://issue.tracker.com/$1 10 | regex: "\\[(\\D+-\\d+)\\]" -------------------------------------------------------------------------------- /src/test/resources/normal/yml/notesConfig.yml: -------------------------------------------------------------------------------- 1 | variants: 2 | - name: project 3 | categories: 4 | - title: Features 5 | regex: feature\/.+ 6 | - title: Bugs 7 | regex: bug\/.+ 8 | links: 9 | - url: https://issue.tracker.com/$1 10 | regex: "\\[(\\D+-\\d+)\\]" -------------------------------------------------------------------------------- /src/test/kotlin/com/micbakos/releasenotes/utilities/SystemErrorStub.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes.utilities 2 | 3 | import java.io.ByteArrayOutputStream 4 | import java.io.PrintStream 5 | 6 | fun stubSystemError(): ByteArrayOutputStream = ByteArrayOutputStream().apply { 7 | System.setErr(PrintStream(this)) 8 | } -------------------------------------------------------------------------------- /src/test/resources/output/output.txt: -------------------------------------------------------------------------------- 1 | **Features** 2 | * [[ID-1000]](https://issue.tracker.com/ID-1000) Add new feature to project #100 3 | * [[ID-1052]](https://issue.tracker.com/ID-1052) Feature of team 1 with another link [[ID-1053]](https://issue.tracker.com/ID-1053) #103 4 | 5 | **Bugs** 6 | * [[ID-1023]](https://issue.tracker.com/ID-1023) Fix nasty bug in project #101 -------------------------------------------------------------------------------- /src/test/resources/git-log/git-log.txt: -------------------------------------------------------------------------------- 1 | Merge pull request #100 from feature/add-new-feature 2 | [ID-1000] Add new feature to project 3 | Merge pull request #101 from bug/fix-bug 4 | [ID-1023] Fix nasty bug in project 5 | Merge pull request #102 from whatever/branch/name 6 | Title of feature that should be ignored 7 | Merge pull request #103 from feature/team1/feature-of-team-1 8 | [ID-1052] Feature of team 1 with another link [ID-1053] 9 | -------------------------------------------------------------------------------- /src/test/resources/normal/both/notesConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": [ 3 | { 4 | "name": "project", 5 | "categories": [ 6 | { 7 | "title": "Features", 8 | "regex": "feature\\/.+" 9 | }, 10 | { 11 | "title": "Bugs", 12 | "regex": "bug\\/.+" 13 | } 14 | ] 15 | } 16 | ], 17 | "links": [ 18 | { 19 | "url": "https://issue.tracker.com/$1", 20 | "regex": "\\[(\\D+-\\d+)\\]" 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /src/test/resources/normal/json/notesConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "variants": [ 3 | { 4 | "name": "project", 5 | "categories": [ 6 | { 7 | "title": "Features", 8 | "regex": "feature\\/.+" 9 | }, 10 | { 11 | "title": "Bugs", 12 | "regex": "bug\\/.+" 13 | } 14 | ] 15 | } 16 | ], 17 | "links": [ 18 | { 19 | "url": "https://issue.tracker.com/$1", 20 | "regex": "\\[(\\D+-\\d+)\\]" 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/micbakos/releasenotes/Writer.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | fun report(pullRequests: Map>): String { 4 | val output = StringBuilder() 5 | pullRequests.entries.forEachIndexed { index, pair -> 6 | if (index > 0) output.appendln().appendln() 7 | 8 | output.appendln("**${pair.key}**") 9 | pair.value.forEachIndexed { prIndex, pr -> 10 | if (prIndex > 0) output.appendln() 11 | output.append("* ${pr.title} ${pr.id}") 12 | } 13 | } 14 | 15 | return output.toString() 16 | } 17 | -------------------------------------------------------------------------------- /src/test/kotlin/com/micbakos/releasenotes/providers/ArgumentsProvider.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes.providers 2 | 3 | import com.micbakos.releasenotes.Arguments 4 | import com.micbakos.releasenotes.Output 5 | 6 | fun arguments( 7 | directory: String = "src/test/resources/normal/both", 8 | variant: String = "project", 9 | fromCommit: String = "d0625b6fd42eaa046df16cecaff2ba7eb625c813", 10 | toCommit: String = "385fe2928332e2b13e24ac73aae8c113e59d9782", 11 | output: Output = Output.StdOutput 12 | ) = Arguments( 13 | directory = directory, 14 | variant = variant, 15 | fromCommit = fromCommit, 16 | toCommit = toCommit, 17 | output = output 18 | ) 19 | -------------------------------------------------------------------------------- /.github/workflows/quality.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 3 | 4 | name: Quality CI 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Set up JDK 1.8 20 | uses: actions/setup-java@v1 21 | with: 22 | java-version: 1.8 23 | - name: Grant execute permission for gradlew 24 | run: chmod +x gradlew 25 | - name: Run unit tests 26 | run: ./gradlew test 27 | -------------------------------------------------------------------------------- /src/test/kotlin/com/micbakos/releasenotes/ReporterTest.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | import com.micbakos.releasenotes.providers.pullRequestsMap 4 | import org.junit.jupiter.api.Assertions.assertEquals 5 | import org.junit.jupiter.api.Test 6 | import java.io.File 7 | 8 | class ReporterTest { 9 | 10 | companion object { 11 | 12 | private const val FILE_OUTPUT = "src/test/resources/output/output.txt" 13 | 14 | } 15 | 16 | @Test 17 | fun `given map of pull requests, when writer is invoked, then the returned output is the expected`() { 18 | val result = report(pullRequestsMap()) 19 | 20 | assertEquals(expectedOutput(), result) 21 | } 22 | 23 | private fun expectedOutput() = File(FILE_OUTPUT).readText() 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/test/kotlin/com/micbakos/releasenotes/providers/PullRequestProvider.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes.providers 2 | 3 | import com.micbakos.releasenotes.PullRequest 4 | 5 | fun pullRequestsMap() = mapOf( 6 | "Features" to listOf( 7 | PullRequest(id = "#100", branch = "feature/add-new-feature", title = "[[ID-1000]](https://issue.tracker.com/ID-1000) Add new feature to project"), 8 | PullRequest(id = "#103", branch = "feature/team1/feature-of-team-1", title = "[[ID-1052]](https://issue.tracker.com/ID-1052) Feature of team 1 with another link [[ID-1053]](https://issue.tracker.com/ID-1053)") 9 | ), 10 | "Bugs" to listOf( 11 | PullRequest(id = "#101", branch = "bug/fix-bug", title = "[[ID-1023]](https://issue.tracker.com/ID-1023) Fix nasty bug in project") 12 | ) 13 | ) -------------------------------------------------------------------------------- /src/main/kotlin/com/micbakos/releasenotes/Notes.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | import java.io.File 4 | 5 | class Notes { 6 | 7 | companion object { 8 | @JvmStatic 9 | fun main(args: Array) { 10 | Notes().start(args) 11 | } 12 | } 13 | 14 | fun start(args: Array) { 15 | val arguments = args.read() 16 | val config = resolveConfig(arguments) 17 | val logResult = gitLog(arguments) 18 | val pullRequests = resolve(logResult, config, arguments) 19 | val output = report(pullRequests) 20 | 21 | print(arguments, output) 22 | } 23 | 24 | private fun print(arguments: Arguments, outputStr: String) { 25 | when (arguments.output) { 26 | is Output.FileOutput -> File(arguments.output.path).writeText(outputStr) 27 | is Output.StdOutput -> println(outputStr) 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/kotlin/com/micbakos/releasenotes/ArgumentsReader.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | import kotlin.system.exitProcess 4 | 5 | fun Array.read(): Arguments { 6 | return if (size in 4..5) { 7 | Arguments( 8 | directory = directory(), 9 | variant = variant(), 10 | fromCommit = fromCommit(), 11 | toCommit = toCommit(), 12 | output = output() 13 | ) 14 | } else { 15 | System.err.println( 16 | "Incorrect arguments. Valid arguments are:\n" + 17 | "\t$ Notes.kts " 18 | ) 19 | exitProcess(0) 20 | } 21 | } 22 | 23 | private fun Array.directory() = get(0) 24 | private fun Array.variant() = get(1) 25 | private fun Array.fromCommit() = get(2) 26 | private fun Array.toCommit() = get(3) 27 | private fun Array.output() = if (size == 5) Output.FileOutput(get(4)) else Output.StdOutput 28 | -------------------------------------------------------------------------------- /src/test/kotlin/com/micbakos/releasenotes/providers/ConfigProvider.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes.providers 2 | 3 | import com.micbakos.releasenotes.Category 4 | import com.micbakos.releasenotes.Config 5 | import com.micbakos.releasenotes.Link 6 | import com.micbakos.releasenotes.Variant 7 | 8 | fun config( 9 | variants: List = listOf(variant()), 10 | links: List = listOf(link()) 11 | ) = Config( 12 | variants = variants, 13 | links = links 14 | ) 15 | 16 | fun variant( 17 | name: String = "project", 18 | categories: List = listOf( 19 | category(), 20 | category("Bugs", "bug\\/.+") 21 | ) 22 | ) = Variant( 23 | name = name, 24 | categories = categories 25 | ) 26 | 27 | fun category( 28 | title: String = "Features", 29 | regex: String = "feature\\/.+" 30 | ) = Category( 31 | title = title, 32 | regex = regex 33 | ) 34 | 35 | fun link( 36 | url: String = "https://issue.tracker.com/\$1", 37 | regex: String = "\\[(\\D+-\\d+)\\]" 38 | ) = Link( 39 | url = url, 40 | regex = regex 41 | ) -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Michael Bakogiannis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/kotlin/com/micbakos/releasenotes/EnvironmentConfig.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | import com.sksamuel.hoplite.ConfigLoader 4 | import java.io.File 5 | import kotlin.system.exitProcess 6 | 7 | fun resolveConfig(arguments: Arguments): Config { 8 | val matches: Array? = File(arguments.directory).listFiles { _, name -> 9 | ProjectConfiguration.VALID_FILE_NAMES.contains(name) 10 | } 11 | 12 | if (matches == null || matches.isEmpty()) { 13 | System.err.println("No file named '${ProjectConfiguration.VALID_FILE_NAMES}' was found inside '${arguments.directory}'") 14 | exitProcess(0) 15 | } else { 16 | if (matches.size > 1) System.out.println("Found multiple configuration files. Loading ${matches[0].name}") 17 | return matches[0].readConfig() 18 | } 19 | } 20 | 21 | fun File.readConfig(): Config { 22 | return try { 23 | ConfigLoader().loadConfigOrThrow(this.toPath()) 24 | } catch (exception: RuntimeException) { 25 | System.err.println("Error parsing ${this.name}") 26 | exception.printStackTrace() 27 | exitProcess(0) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/kotlin/com/micbakos/releasenotes/GitLogger.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | import java.io.File 4 | import java.util.concurrent.TimeUnit 5 | import kotlin.system.exitProcess 6 | 7 | fun gitLog(arguments: Arguments): String { 8 | // A command consists of a list of strings that will be fed to the process builder sequentially 9 | val command = listOf( 10 | "git", 11 | "log", 12 | "${arguments.fromCommit}..${arguments.toCommit}", // The range of commits to show 13 | "--format=%s%n%b", // The format as of: Title\nBody 14 | "--merges", // Accept only merge commits 15 | "--grep=Merge pull request" // Filter commits which are actualy pull request merges 16 | ) 17 | 18 | return command.execute(File(arguments.directory)) 19 | } 20 | 21 | 22 | /** Extension method on List that executes the sequence of string commands in the given directory */ 23 | fun List.execute(directory: File): String { 24 | val process = ProcessBuilder(this) 25 | .directory(directory) 26 | .start() 27 | .also { it.waitFor(10, TimeUnit.SECONDS) } 28 | 29 | if (process.exitValue() != 0) { 30 | System.err.write(process.errorStream.readBytes()) 31 | exitProcess(process.exitValue()) 32 | } 33 | 34 | return process.inputStream.bufferedReader().readText().trim() 35 | } 36 | -------------------------------------------------------------------------------- /src/main/kotlin/com/micbakos/releasenotes/Models.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | /** 4 | * Need a class to be able to use a const val, since top level constants are not supported 5 | */ 6 | class ProjectConfiguration { 7 | 8 | companion object { 9 | private const val JSON_SUFFIX = ".json" 10 | private const val YAML_SUFFIX = ".yaml" 11 | private const val YML_SUFFIX = ".yml" 12 | private const val FILE_NAME_PREFIX = "notesConfig" 13 | val VALID_FILE_NAMES: List = listOf( 14 | FILE_NAME_PREFIX + JSON_SUFFIX, 15 | FILE_NAME_PREFIX + YAML_SUFFIX, 16 | FILE_NAME_PREFIX + YML_SUFFIX 17 | ) 18 | const val PULL_REQUEST_ID_REGEX = "(#\\d+)" 19 | } 20 | 21 | } 22 | 23 | data class Arguments( 24 | val directory: String, 25 | val variant: String, 26 | val fromCommit: String, 27 | val toCommit: String, 28 | val output: Output 29 | ) 30 | 31 | sealed class Output { 32 | object StdOutput : Output() 33 | data class FileOutput(val path: String) : Output() 34 | } 35 | 36 | data class PullRequest( 37 | val id: String, 38 | val branch: String, 39 | val title: String 40 | ) 41 | 42 | data class Config( 43 | val variants: List, 44 | val links: List 45 | ) 46 | 47 | data class Variant( 48 | val name: String, 49 | val categories: List 50 | ) 51 | 52 | data class Category( 53 | val title: String, 54 | val regex: String 55 | ) 56 | 57 | data class Link( 58 | val url: String, 59 | val regex: String 60 | ) 61 | -------------------------------------------------------------------------------- /src/test/kotlin/com/micbakos/releasenotes/PullRequestResolverTest.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | import com.ginsberg.junit.exit.ExpectSystemExitWithStatus 4 | import com.micbakos.releasenotes.providers.arguments 5 | import com.micbakos.releasenotes.providers.config 6 | import com.micbakos.releasenotes.providers.pullRequestsMap 7 | import com.micbakos.releasenotes.utilities.stubSystemError 8 | import org.junit.jupiter.api.Assertions.assertEquals 9 | import org.junit.jupiter.api.Test 10 | import java.io.File 11 | 12 | class PullRequestResolverTest { 13 | 14 | companion object { 15 | 16 | private const val PROJECT_DIR = "src/test/resources/normal/json" 17 | private const val FILE_GIT_LOG = "src/test/resources/git-log/git-log.txt" 18 | 19 | } 20 | 21 | @Test 22 | fun `given git log and correct arguments, when resolving the log, the map of pull requests are the expected ones`() { 23 | val gitLog = File(FILE_GIT_LOG).readText() 24 | val arguments = arguments(directory = PROJECT_DIR) 25 | val config = config() 26 | 27 | val pullRequests = resolve(gitLog, config, arguments) 28 | 29 | assertEquals(pullRequestsMap(), pullRequests) 30 | } 31 | 32 | @Test 33 | @ExpectSystemExitWithStatus(0) 34 | fun `given git log and incorrect variant name, when resolving the log, the error is print in std err`() { 35 | val gitLog = File(FILE_GIT_LOG).readText() 36 | val arguments = arguments(directory = PROJECT_DIR) 37 | val config = config(variants = listOf(Variant("Whatever", categories = listOf()))) 38 | val error = stubSystemError() 39 | 40 | resolve(gitLog, config, arguments) 41 | 42 | assertEquals("Variant named: Whatever does not exist in file loaded.", error.toString()) 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /src/test/kotlin/com/micbakos/releasenotes/ArgumentsReaderTest.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | import com.ginsberg.junit.exit.ExpectSystemExitWithStatus 4 | import com.micbakos.releasenotes.utilities.stubSystemError 5 | import org.junit.jupiter.api.Assertions.assertEquals 6 | import org.junit.jupiter.api.Test 7 | 8 | internal class ArgumentsReaderTest { 9 | 10 | companion object { 11 | 12 | private const val TEST_DIR = "some/directory/to/project" 13 | private const val TEST_VARIANT = "project1" 14 | private const val TEST_FROM_COMMIT = "d0625b6fd42eaa046df16cecaff2ba7eb625c813" 15 | private const val TEST_TO_COMMIT = "385fe2928332e2b13e24ac73aae8c113e59d9782" 16 | private const val TEST_FILE_OUTPUT = "path/to/output.md" 17 | } 18 | 19 | @Test 20 | fun `given array of four arguments, when read is invoked, then the result arguments is the expected`() { 21 | val input = arrayOf(TEST_DIR, TEST_VARIANT, TEST_FROM_COMMIT, TEST_TO_COMMIT) 22 | 23 | val result = input.read() 24 | 25 | assertEquals( 26 | Arguments( 27 | directory = TEST_DIR, 28 | variant = TEST_VARIANT, 29 | fromCommit = TEST_FROM_COMMIT, 30 | toCommit = TEST_TO_COMMIT, 31 | output = Output.StdOutput 32 | ), result 33 | ) 34 | } 35 | 36 | @Test 37 | fun `given array of five arguments, when read is invoked, then the result arguments is the expected`() { 38 | val input = arrayOf(TEST_DIR, TEST_VARIANT, TEST_FROM_COMMIT, TEST_TO_COMMIT, TEST_FILE_OUTPUT) 39 | 40 | val result = input.read() 41 | 42 | assertEquals( 43 | Arguments( 44 | directory = TEST_DIR, 45 | variant = TEST_VARIANT, 46 | fromCommit = TEST_FROM_COMMIT, 47 | toCommit = TEST_TO_COMMIT, 48 | output = Output.FileOutput(TEST_FILE_OUTPUT) 49 | ), result 50 | ) 51 | } 52 | 53 | @Test 54 | @ExpectSystemExitWithStatus(0) 55 | fun `given array of less arguments, when read is invoked, then the process terminates with status 0`() { 56 | val input = arrayOf(TEST_DIR, TEST_VARIANT, TEST_FROM_COMMIT) 57 | stubSystemError() 58 | 59 | input.read() 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/kotlin/com/micbakos/releasenotes/PullRequestResolver.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | import kotlin.system.exitProcess 4 | 5 | fun resolve(log: String, config: Config, arguments: Arguments): Map> { 6 | val output = log.lines() 7 | val pullRequestCategories = mutableMapOf>() 8 | for (line in 0..(output.size - 2) step 2) { 9 | // A pull request is analyzed in every two lines as described in the --format command 10 | val commitTitle = output[line] 11 | val body = output[line + 1] 12 | 13 | val variant = ensureVariant(config, arguments) 14 | 15 | val category = findMatchedCategory(variant, commitTitle) ?: continue 16 | 17 | val branchName = category.regex.toRegex().find(commitTitle)?.value ?: continue 18 | 19 | val pullRequestId = ProjectConfiguration.PULL_REQUEST_ID_REGEX.toRegex() 20 | .find(commitTitle)?.value ?: continue 21 | 22 | val bodyWithLinks = resolveLinks(config, body) 23 | 24 | val pullRequest = PullRequest(pullRequestId, branchName, bodyWithLinks) 25 | pullRequestCategories[category.title]?.add(pullRequest) ?: run { 26 | pullRequestCategories[category.title] = arrayListOf(pullRequest) 27 | } 28 | } 29 | 30 | return pullRequestCategories 31 | } 32 | 33 | private fun ensureVariant(config: Config, arguments: Arguments): Variant { 34 | return config.variants.find { it.name == arguments.variant } ?: run { 35 | System.err.println("Variant named: ${arguments.variant} does not exist in file loaded.") 36 | exitProcess(0) 37 | } 38 | } 39 | 40 | private fun findMatchedCategory(variant: Variant, commitTitle: String): Category? { 41 | return variant.categories.find { 42 | it.regex.toRegex().containsMatchIn(commitTitle) 43 | } 44 | } 45 | 46 | private fun resolveLinks(config: Config, rawBody: String): String { 47 | var body = rawBody 48 | config.links.forEach { link -> 49 | val regex = link.regex.toRegex() 50 | 51 | regex.findAll(rawBody).forEach { 52 | val matchedLink = it.value 53 | val replacement = matchedLink.replace(regex, link.url) 54 | body = body.replace(matchedLink, "[$matchedLink]($replacement)") 55 | } 56 | } 57 | return body 58 | } 59 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /src/test/kotlin/com/micbakos/releasenotes/EnvironmentConfigTest.kt: -------------------------------------------------------------------------------- 1 | package com.micbakos.releasenotes 2 | 3 | import com.ginsberg.junit.exit.ExpectSystemExitWithStatus 4 | import com.micbakos.releasenotes.providers.arguments 5 | import com.micbakos.releasenotes.providers.config 6 | import com.micbakos.releasenotes.utilities.stubSystemError 7 | import org.junit.jupiter.api.Assertions.assertEquals 8 | import org.junit.jupiter.api.DisplayName 9 | import org.junit.jupiter.api.Nested 10 | import org.junit.jupiter.api.Test 11 | 12 | class EnvironmentConfigTest { 13 | 14 | companion object { 15 | 16 | private const val DIR_NORMAL_BOTH = "src/test/resources/normal/both" 17 | private const val DIR_NORMAL_JSON = "src/test/resources/normal/json" 18 | private const val DIR_NORMAL_YML = "src/test/resources/normal/yml" 19 | 20 | private const val DIR_MALFORMED_BOTH = "src/test/resources/malformed/both" 21 | private const val DIR_MALFORMED_JSON = "src/test/resources/malformed/json" 22 | private const val DIR_MALFORMED_YML = "src/test/resources/malformed/yml" 23 | 24 | } 25 | 26 | @Nested 27 | @DisplayName("Correct configuration") 28 | inner class NormalParsing { 29 | 30 | @Test 31 | fun `given both files, when resolving config, then the expected config is returned`() { 32 | val arguments = arguments(directory = DIR_NORMAL_BOTH) 33 | 34 | val result = resolveConfig(arguments) 35 | 36 | assertEquals(config(), result) 37 | } 38 | 39 | @Test 40 | fun `given json file, when resolving config, then the expected config is returned`() { 41 | val arguments = arguments(directory = DIR_NORMAL_JSON) 42 | 43 | val result = resolveConfig(arguments) 44 | 45 | assertEquals(config(), result) 46 | } 47 | 48 | @Test 49 | fun `given yml file, when resolving config, then the expected config is returned`() { 50 | val arguments = arguments(directory = DIR_NORMAL_YML) 51 | 52 | val result = resolveConfig(arguments) 53 | 54 | assertEquals(config(), result) 55 | } 56 | 57 | } 58 | 59 | @Nested 60 | @DisplayName("Wrong directory") 61 | inner class WrongConfiguration { 62 | 63 | @Test 64 | @ExpectSystemExitWithStatus(0) 65 | fun `given directory with no config file, when resolving config, then the correct error is print out in std err`() { 66 | val directory = "/dir" 67 | val arguments = arguments(directory = directory) 68 | val errorStream = stubSystemError() 69 | 70 | resolveConfig(arguments) 71 | 72 | assertEquals( 73 | "No file named '[notesConfig.json, notesConfig.yaml, notesConfig.yml]' was found inside '$directory'", 74 | errorStream.toString() 75 | ) 76 | } 77 | 78 | } 79 | 80 | @Nested 81 | @DisplayName("Malformed configuration files") 82 | inner class MalformedConfFiles { 83 | 84 | @Test 85 | @ExpectSystemExitWithStatus(0) 86 | fun `given directory with both malformed files, when resolving config, then the correct error is print out in std err`() { 87 | val arguments = arguments(directory = DIR_MALFORMED_BOTH) 88 | val errorStream = stubSystemError() 89 | 90 | resolveConfig(arguments) 91 | 92 | assertEquals( 93 | "Error parsing notesConfig.json", 94 | errorStream.toString() 95 | ) 96 | } 97 | 98 | @Test 99 | @ExpectSystemExitWithStatus(0) 100 | fun `given directory with json malformed file, when resolving config, then the correct error is print out in std err`() { 101 | val arguments = arguments(directory = DIR_MALFORMED_JSON) 102 | val errorStream = stubSystemError() 103 | 104 | resolveConfig(arguments) 105 | 106 | assertEquals( 107 | "Error parsing notesConfig.json", 108 | errorStream.toString() 109 | ) 110 | } 111 | 112 | @Test 113 | @ExpectSystemExitWithStatus(0) 114 | fun `given directory with yml malformed files, when resolving config, then the correct error is print out in std err`() { 115 | val arguments = arguments(directory = DIR_MALFORMED_YML) 116 | val errorStream = stubSystemError() 117 | 118 | resolveConfig(arguments) 119 | 120 | assertEquals( 121 | "Error parsing notesConfig.yml", 122 | errorStream.toString() 123 | ) 124 | } 125 | 126 | } 127 | 128 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Quality CI](https://github.com/micbakos/ReleaseNotes/workflows/Quality%20CI/badge.svg) 2 | 3 | # Release Notes 4 | 5 | This repository contains a simple script that compiles a list of pull request merge commits and uses them to display a readbale list of release notes. 6 | 7 | ## Reasoning 8 | This script is currently used by the [Beat](https://github.com/beatlabs) mobile team. The organization abides by the scrum agile methodology and the mobile team follows the git flow branching model. Before every release the team compiles 9 | all the work that has been done on each sprint. The final document is a list of Github's Pull Requests that link to a Jira issue ticket. 10 | 11 | This goal of this script is to laverage the infrastracture of the company and the mobile team's workflow to automate this task. The release notes are compiled into a Markdown file. 12 | 13 | ## Dynamic configuration 14 | In order for the script to run dynamically, the user needs to create a configuration file (in Json or Yaml format) and place it anywhere inside their project. **The file needs to be named `notesConfig.[json|yaml|yml]`** 15 | 16 | The configuration file needs to define the following attributes: 17 | - `variants`: Each variant is a representation of a project that outputs release notes. Some repositories may consist of more than one project. 18 | - `name`: This is the name of the project that is also given to the script input in order to identify which notes to output. 19 | - `categories`: Each category is a set of pull requests that can be grouped together. 20 | - `title`: The title to output before the list of pull requests of each category. 21 | - `regex`: The regex representation of the branch that belongs to the given category. 22 | - `links`: The title of the given pull request may contain links to issues on an issue tracker. This object describes the information needed to replace the issue ids with links to the actuall issue. 23 | - `regex`: The regex representation of an issue. 24 | - `url`: The replacement url of each issue in order to transform it to a link. 25 | 26 | ### Example of a configuration file: 27 | 28 | #### Yaml 29 | ```yaml 30 | 31 | variants: 32 | - name: passenger 33 | categories: 34 | - title: Product 35 | regex: taxibeat\/(passenger|all)\/(feature)\/(?!infra).+\/.+ 36 | - title: Infra 37 | regex: taxibeat\/(passenger|all)\/(feature|chapter)\/infra\/.+ 38 | - title: Bugs 39 | regex: taxibeat\/(passenger|all)\/(bugfix|hotfix)\/.+ 40 | - name: driver 41 | categories: 42 | - title: Product 43 | regex: taxibeat\/(driver|all)\/(feature)\/(?!infra).+\/.+ 44 | - title: Infra 45 | regex: taxibeat\/(driver|all)\/(feature|chapter)\/infra\/.+ 46 | - title: Bugs 47 | regex: taxibeat\/(driver|all)\/(bugfix|hotfix)\/.+ 48 | links: 49 | - url: https://jira.taxibeat.com/browse/$1 50 | regex: "\\[(\\D+-\\d+)\\]" 51 | 52 | ``` 53 | 54 | #### JSON 55 | ```json 56 | { 57 | "variants": [ 58 | { 59 | "name": "passenger", 60 | "categories": [ 61 | { 62 | "title": "Product", 63 | "regex": "taxibeat\\/(passenger|all)\\/(feature)\\/(?!infra).+\\/.+" 64 | }, 65 | { 66 | "title": "Infra", 67 | "regex": "taxibeat\\/(passenger|all)\\/(feature|chapter)\\/infra\\/.+" 68 | }, 69 | { 70 | "title": "Bugs", 71 | "regex": "taxibeat\\/(passenger|all)\\/(bugfix|hotfix)\\/.+" 72 | } 73 | ] 74 | }, 75 | { 76 | "name": "driver", 77 | "categories": [ 78 | { 79 | "title": "Product", 80 | "regex": "taxibeat\\/(driver|all)\\/(feature)\\/(?!infra).+\\/.+" 81 | }, 82 | { 83 | "title": "Infra", 84 | "regex": "taxibeat\\/(driver|all)\\/(feature|chapter)\\/infra\\/.+" 85 | }, 86 | { 87 | "title": "Bugs", 88 | "regex": "taxibeat\\/(driver|all)\\/(bugfix|hotfix)\\/.+" 89 | } 90 | ] 91 | } 92 | ], 93 | "links": [ 94 | { 95 | "url": "https://jira.taxibeat.com/browse/$1", 96 | "regex": "\\[(\\D+-\\d+)\\]" 97 | } 98 | ] 99 | } 100 | 101 | ``` 102 | This project contains two variants: **passenger** and **driver**. These names can be used when running the script to output the release notes of each project. 103 | Each variant contains categories such as `Product`, `Infra` and `Bugs`. These categories are distinguised themselves by the structure of the branch from which they are merged. 104 | Finally the every issue id occurance can be replaced with the issue's link. 105 | 106 | ## Output format 107 | The output is printed in Markdown style with the following format 108 | ``` 109 | **Category 1** 110 | #<pull request id> 111 | <Title of pull request> #<pull request id> 112 | ... 113 | **Category 2** 114 | <Title of pull request> #<pull request id> 115 | ... 116 | ``` 117 | 118 | ## Installation and running 119 | 120 | #### Manual installation 121 | * Clone the project 122 | * Run notes script with the following command inside the `ReleaseNotes/` directory 123 | ``` 124 | ./notes /path/to/project variant FROM-RELEASE-TAG TO-RELEASE-TAG /path/to/output/file 125 | ``` 126 | 127 | #### Installation with Homebrew 128 | * Run the following command 129 | ```bash 130 | brew install micbakos/tap/release-notes 131 | ``` 132 | * And then run with the following command 133 | ```bash 134 | notes /path/to/project variant FROM-RELEASE-TAG TO-RELEASE-TAG /path/to/output/file 135 | ``` 136 | 137 | #### Arguments: 138 | * The path of the project's location 139 | * The chosen variant as defined in the configuration file 140 | * The commit from which the script will search the merge commits 141 | * The commit to which the script will stop the search 142 | * [OPTIONAL] The output file path. If no file specified the script will report to std-out. 143 | 144 | Both of the from-to attributes can be represented by the commit's hash or tag. 145 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | --------------------------------------------------------------------------------