Skip to content

Commit 67a9818

Browse files
authored
Make -Prelease.overriddenBranchName work in non-detached state (#887)
1 parent fcf088b commit 67a9818

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/pl/allegro/tech/build/axion/release/infrastructure/git/GitRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ private String branchNameFromGit() {
387387
.map(Repository::shortenRefName)
388388
.orElse(null);
389389

390-
if ("HEAD".equals(branchName) && properties.getOverriddenBranchName() != null && !properties.getOverriddenBranchName().isEmpty()) {
390+
if (properties.getOverriddenBranchName() != null && !properties.getOverriddenBranchName().isEmpty()) {
391391
branchName = Repository.shortenRefName(properties.getOverriddenBranchName());
392392
}
393393
return branchName;

src/test/groovy/pl/allegro/tech/build/axion/release/infrastructure/git/GitRepositoryTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class GitRepositoryTest extends Specification {
367367
position.branch == 'feature/overridden-branch-name'
368368
}
369369

370-
def "should ignore overriddenBranchName when not in detached state"() {
370+
def "should not ignore overriddenBranchName when not in detached state"() {
371371
given:
372372
File repositoryDir = File.createTempDir('axion-release', 'tmp')
373373
def scmProperties = scmProperties(repositoryDir)
@@ -384,7 +384,7 @@ class GitRepositoryTest extends Specification {
384384
ScmPosition position = repository.currentPosition()
385385

386386
then:
387-
position.branch == 'some-branch'
387+
position.branch == 'feature/overridden-branch-name'
388388
}
389389

390390
def "should push changes and tag to remote"() {

0 commit comments

Comments
 (0)