Skip to content

Commit

Permalink
fix: allow GitHub PR branches with /
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Dec 16, 2019
1 parent 59bb812 commit a0e845e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
2 changes: 1 addition & 1 deletion services/github.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://help.github.com/en/articles/virtual-environments-for-github-actions#environment-variables

const parseBranch = branch => (/^(?:refs\/heads\/)?([^/]+)$/i.exec(branch) || [])[1];
const parseBranch = branch => (/^(?:refs\/heads\/)?(.+)$/i.exec(branch) || [])[1];

const getPrEvent = ({env}) => {
try {
Expand Down
28 changes: 0 additions & 28 deletions test/services/github.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,31 +193,3 @@ test('PR - with missing "pull_request.base" in event.json file', t => {
}
);
});

test('PR - with erronous branch names', t => {
const eventFile = tempy.file({extension: 'json'});
const event = {pull_request: {number: '10', base: {ref: 'refs/tags/master'}}};
fs.writeFileSync(eventFile, JSON.stringify(event));

t.deepEqual(
github.configuration({
env: {
...env,
GITHUB_EVENT_NAME: 'pull_request',
GITHUB_REF: 'refs/tags/pr-branch',
GITHUB_EVENT_PATH: eventFile,
},
}),
{
name: 'GitHub Actions',
service: 'github',
commit: '1234',
branch: undefined,
isPr: true,
prBranch: undefined,
pr: '10',
root: '/workspace',
slug: 'owner/repo',
}
);
});

0 comments on commit a0e845e

Please sign in to comment.