Skip to content

Commit

Permalink
fix(1537): Fix ~pr trigger and ~pr:branch trigger have the same behav…
Browse files Browse the repository at this point in the history
…ior (#22)
  • Loading branch information
kumada626 authored and tkyi committed May 9, 2019
1 parent 6876ab9 commit eab8995
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/getNextJobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ const getNextJobs = (workflowGraph, config) => {
if (triggerBranch && triggerBranch[1] === edgeSrcBranch[1]) {
// Check if trigger branch and edge src branch regex match
if (triggerBranch[2].match(edgeSrcBranch[2])) {
jobs.add(edge.dest);
if (config.trigger.startsWith('~pr')) {
jobs.add(`PR-${config.prNum}:${edge.dest}`);
} else {
jobs.add(edge.dest);
}
}
}
} else if (edge.src === config.trigger) {
// Make PR jobs PR-$num:$cloneJob (not sure how to better handle multiple PR jobs)
if (config.trigger === '~pr') {
if (config.trigger === '~pr' || config.trigger.startsWith('~pr:')) {
jobs.add(`PR-${config.prNum}:${edge.dest}`);
} else {
jobs.add(edge.dest);
Expand Down
6 changes: 3 additions & 3 deletions test/lib/getNextJobs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ describe('getNextJobs', () => {
['c', 'd']);
// trigger by a pull request on "foo" branch
assert.deepEqual(getNextJobs(specificBranchWorkflow, { trigger: '~pr:foo', prNum: '123' }),
['e']);
['PR-123:e']);
// trigger by a pull request on "foo-bar-dev" branch
assert.deepEqual(getNextJobs(specificBranchWorkflow, { trigger: '~pr:foo-bar-dev',
prNum: '123' }), ['f']);
prNum: '123' }), ['PR-123:f']);
// trigger by a pull request on "bar-foo-prod" branch
assert.deepEqual(getNextJobs(specificBranchWorkflow, { trigger: '~pr:bar-foo-prod',
prNum: '123' }), ['f', 'g']);
prNum: '123' }), ['PR-123:f', 'PR-123:g']);
});
});

0 comments on commit eab8995

Please sign in to comment.