Skip to content

Commit

Permalink
Merge pull request #12 from ilovemilk/develop
Browse files Browse the repository at this point in the history
Version 2.0.1
  • Loading branch information
ilovemilk authored Feb 3, 2020
2 parents 0cd041a + 1056c8c commit aa80488
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ 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).

## [Unreleased]
## [2.0.1]
### Fixed
- Branch parsing regex now supports camelCase

## [2.0.0]
### Added
- Custom branch specific formatter

Expand All @@ -21,4 +25,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.1.0] - 2019-05-07
### Added
- Custom initial version.
- Custom initial version.
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.0"
version = "2.0.1"

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-z_-]*/?[a-z_-]+)\s+[0-9a-z]{40}""".toRegex().find(branches)!!.groupValues[3]
"""(remotes)*/*(origin)*/*([a-zA-Z_-]*/?[a-zA-Z_-]+)\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
20 changes: 19 additions & 1 deletion src/test/kotlin/io/wusa/GitServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ class GitServiceTest {
Assertions.assertEquals("feature/test", GitService.currentBranch(project))
}

@Test
fun `get current branch feature-reactiveTests with origin`() {
every { GitCommandRunner.execute(projectDir = any(), args = any()) } returns
"* feature/reactiveTests 831965a6c57434276c70c8e1134244dd6077b1fc fix tests with timeout\n" +
" hotfix/codePrefix 4ad7116a019553ff19d0e338bf7e602374d72c04 [behind 1] fixed publish code test for added prefix\n" +
" remotes/origin/develop 13fc04d392d51d9bc7b70c8d52b2d8cd6cc1199a Merge branch 'feature/reactive-tests' into 'develop'\n" +
" remotes/origin/hotfix/codePrefix a3b40aa8be599003c8656d5cc9a460ffd61fe1f9 escaping / in regex for branch detection\n"
Assertions.assertEquals("feature/reactiveTests", GitService.currentBranch(project))
}

@Test
fun `get current branch hotfix-codePrefix with origin`() {
every { GitCommandRunner.execute(projectDir = any(), args = any()) } returns
"* hotfix/codePrefix 4ad7116a019553ff19d0e338bf7e602374d72c04 [behind 1] fixed publish code test for added prefix\n" +
" remotes/origin/hotfix/codePrefix a3b40aa8be599003c8656d5cc9a460ffd61fe1f9 escaping / in regex for branch detection"
Assertions.assertEquals("hotfix/codePrefix", GitService.currentBranch(project))
}

@Test
fun `get current branch with null pointer exception`() {
every { GitCommandRunner.execute(projectDir = any(), args = any()) } throws KotlinNullPointerException()
Expand All @@ -128,4 +146,4 @@ class GitServiceTest {
GitService.currentBranch(project)
}
}
}
}

0 comments on commit aa80488

Please sign in to comment.