Skip to content

Commit

Permalink
Fix: Fix PR flow on pull_request_target
Browse files Browse the repository at this point in the history
  • Loading branch information
politician committed Oct 1, 2020
1 parent 4049d86 commit ee5bd2a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
11 changes: 5 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions src/copybaraAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ export class CopybaraAction {

getCurrentBranch() {
if (!this.current.branch) {
let ref = "";
if (context.payload.pull_request && /^refs\/heads\//.test(context.payload.pull_request.base.ref))
ref = context.payload.pull_request.base.ref;
else if (/^refs\/heads\//.test(context.ref)) ref = context.ref;
else throw `Cannot determine head branch from ${context.payload.base_ref} and ${context.ref}`;
this.current.branch = ref.replace(/^refs\/heads\//, "");
if (context.payload.pull_request && context.payload.pull_request.base.ref)
this.current.branch = context.payload.pull_request.base.ref;
else if (/^refs\/heads\//.test(context.ref)) this.current.branch = context.ref.replace(/^refs\/heads\//, "");
else throw `Cannot determine head branch from ${context.payload.pull_request?.base.ref} and ${context.ref}`;
}
core.debug(`Current branch is ${this.current.branch}`);
return this.current.branch;
Expand Down

0 comments on commit ee5bd2a

Please sign in to comment.