From d4e949cd7a2e6b10acdf0a344550a528bff4b3b2 Mon Sep 17 00:00:00 2001 From: Damjan Becirovic Date: Thu, 22 Apr 2021 12:33:58 +0200 Subject: [PATCH] Support commit_range env var in branch_range config --- pkg/when/changein/parser.go | 5 +++++ test/e2e/change_in_branch_range.rb | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/when/changein/parser.go b/pkg/when/changein/parser.go index 452cb55..1fa1ce9 100644 --- a/pkg/when/changein/parser.go +++ b/pkg/when/changein/parser.go @@ -182,6 +182,11 @@ func (p *parser) BranchRange(defaultBranch string) (string, error) { return "", err } + if found && branchRange == "$SEMAPHORE_GIT_COMMIT_RANGE" { + branchRange = p.fetchCommitRange(defaultBranch) + return branchRange, nil + } + if !found { branchRange = "$SEMAPHORE_MERGE_BASE...$SEMAPHORE_GIT_SHA" } diff --git a/test/e2e/change_in_branch_range.rb b/test/e2e/change_in_branch_range.rb index 8b58f31..02c1111 100644 --- a/test/e2e/change_in_branch_range.rb +++ b/test/e2e/change_in_branch_range.rb @@ -26,6 +26,10 @@ - name: Test4 run: when: "branch = 'master' and change_in(['/lib', 'log.txt'], {branch_range: 'dev...$SEMAPHORE_GIT_SHA'})" + + - name: Test5 + run: + when: "branch = 'master' and change_in(['/lib'], {branch_range: '$SEMAPHORE_GIT_COMMIT_RANGE'})" } origin = TestRepoForChangeIn.setup() @@ -74,4 +78,8 @@ - name: Test4 run: when: "(branch = 'master') and true" + + - name: Test5 + run: + when: "(branch = 'master') and true" }))