Skip to content

Commit

Permalink
Support commit_range env var in branch_range config
Browse files Browse the repository at this point in the history
  • Loading branch information
DamjanBecirovic committed Apr 22, 2021
1 parent cd82bf8 commit d4e949c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/when/changein/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/change_in_branch_range.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -74,4 +78,8 @@
- name: Test4
run:
when: "(branch = 'master') and true"
- name: Test5
run:
when: "(branch = 'master') and true"
}))

0 comments on commit d4e949c

Please sign in to comment.