Skip to content

Commit

Permalink
Merge pull request #13 from ilovemilk/feature/fix-branch-regex
Browse files Browse the repository at this point in the history
fix number special case for branch regex
  • Loading branch information
ilovemilk authored Feb 13, 2020
2 parents 1056c8c + 3e649be commit 92d7bde
Show file tree
Hide file tree
Showing 5 changed files with 15 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.0.2]
### Fixed
- Branch parsing regex now supports numbers [0-9]

## [2.0.1]
### Fixed
- Branch parsing regex now supports camelCase
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.0.0")
id("io.wusa.semver-git-plugin").version("2.0.2")
}
```

Expand All @@ -25,7 +25,7 @@ buildscript {
}
}
dependencies {
classpath 'io.wusa:semver-git-plugin:2.0.0'
classpath 'io.wusa:semver-git-plugin:2.0.2'
}
}
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.0.1"
version = "2.0.2"

dependencies {
implementation(kotlin("stdlib-jdk8"))
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/wusa/GitService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
7 changes: 7 additions & 0 deletions src/test/kotlin/io/wusa/GitServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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`() {
Expand Down

0 comments on commit 92d7bde

Please sign in to comment.