From bb6c65bd46ad18edb7ecc7fa3049615f420cffa7 Mon Sep 17 00:00:00 2001 From: Matthais Held Date: Thu, 13 Feb 2020 13:12:27 +0100 Subject: [PATCH 1/2] fix number special case --- src/main/kotlin/io/wusa/GitService.kt | 2 +- src/test/kotlin/io/wusa/GitServiceTest.kt | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/io/wusa/GitService.kt b/src/main/kotlin/io/wusa/GitService.kt index 7ae4091..7e49ec1 100644 --- a/src/main/kotlin/io/wusa/GitService.kt +++ b/src/main/kotlin/io/wusa/GitService.kt @@ -81,7 +81,7 @@ class GitService { } private fun filterCurrentBranch(branches: String) = - """(remotes)*/*(origin)*/*([a-zA-Z_-]*/?[a-zA-Z_-]+)\s+[0-9a-zA-Z]{40}""".toRegex().find(branches)!!.groupValues[3] + """(remotes)*/*(origin)*/*([a-zA-Z0-9_-]*/?[a-zA-Z0-9_-]+)\s+[0-9a-zA-Z]{40}""".toRegex().find(branches)!!.groupValues[3] private fun getAllBranches(project: Project): String { return GitCommandRunner.execute(project.projectDir, arrayOf("branch", "--all", "--verbose", "--no-abbrev", "--contains")) diff --git a/src/test/kotlin/io/wusa/GitServiceTest.kt b/src/test/kotlin/io/wusa/GitServiceTest.kt index 5849cca..45d5c95 100644 --- a/src/test/kotlin/io/wusa/GitServiceTest.kt +++ b/src/test/kotlin/io/wusa/GitServiceTest.kt @@ -130,6 +130,13 @@ class GitServiceTest { " remotes/origin/hotfix/codePrefix a3b40aa8be599003c8656d5cc9a460ffd61fe1f9 escaping / in regex for branch detection" Assertions.assertEquals("hotfix/codePrefix", GitService.currentBranch(project)) } + @Test + fun `get current branch feature-s-version-3 with origin`() { + every { GitCommandRunner.execute(projectDir = any(), args = any()) } returns + "* feature/s-version-3 9ea487bb167c89a6453fd2e72740a492c6782887 use kebab case\n" + + " remotes/origin/feature/s-version-3 9ea487bb167c89a6453fd2e72740a492c6782887 use kebab case" + Assertions.assertEquals("feature/s-version-3", GitService.currentBranch(project)) + } @Test fun `get current branch with null pointer exception`() { From 3e649be50467ac2cae1c7d7b6d9fbd5b955d7e82 Mon Sep 17 00:00:00 2001 From: Matthais Held Date: Thu, 13 Feb 2020 13:13:46 +0100 Subject: [PATCH 2/2] bump version --- CHANGELOG.md | 4 ++++ README.md | 4 ++-- build.gradle.kts | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be482df..70a46d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.0.2] +### Fixed +- Branch parsing regex now supports numbers [0-9] + ## [2.0.1] ### Fixed - Branch parsing regex now supports camelCase diff --git a/README.md b/README.md index ad372b3..57266e7 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Gradle 2.1 and higher ``` plugins { - id("io.wusa.semver-git-plugin").version("2.0.0") + id("io.wusa.semver-git-plugin").version("2.0.2") } ``` @@ -25,7 +25,7 @@ buildscript { } } dependencies { - classpath 'io.wusa:semver-git-plugin:2.0.0' + classpath 'io.wusa:semver-git-plugin:2.0.2' } } diff --git a/build.gradle.kts b/build.gradle.kts index 6d246ad..a921af7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "io.wusa" -version = "2.0.1" +version = "2.0.2" dependencies { implementation(kotlin("stdlib-jdk8"))