diff --git a/build.gradle.kts b/build.gradle.kts index ca625e0..9a1b7fb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "io.wusa" -version = "2.3.7" +version = "2.3.8" dependencies { implementation(kotlin("stdlib-jdk8")) diff --git a/src/main/kotlin/io/wusa/GitService.kt b/src/main/kotlin/io/wusa/GitService.kt index ed073b2..121783d 100644 --- a/src/main/kotlin/io/wusa/GitService.kt +++ b/src/main/kotlin/io/wusa/GitService.kt @@ -102,8 +102,12 @@ class GitService { } private fun getCurrentBranch(project: Project): String { - val head = GitCommandRunner.execute(project.projectDir, arrayOf("log", "-n", "1", "--pretty=%d", "HEAD")) - return """\([grafted, ]{0,9}HEAD -> (.*?)[,|)]""".toRegex().find(head)!!.groupValues[1] + var branchName: String? = System.getenv("BRANCH_NAME") + if (branchName == null) { + val head = GitCommandRunner.execute(project.projectDir, arrayOf("log", "-n", "1", "--pretty=%d", "HEAD")) + branchName = """\([grafted, ]{0,9}HEAD(?: -> |,)(?:(\S+),|\)|.*,(?: origin\/| )(\S+)\))""".toRegex().find(head)!!.groupValues.filter { it != "" }[1] + } + return branchName } } }