Skip to content

Commit

Permalink
fix(2029): Add prSource to prInfo return value (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumada626 authored Apr 17, 2020
1 parent af36178 commit b49641b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,9 @@ class GithubScm extends Scm {
repo: scmInfo.repo
}
});
const prSource = pullRequestInfo.data.head.repo.id === pullRequestInfo.data.base.repo.id
? 'branch'
: 'fork';

return {
name: `PR-${pullRequestInfo.data.number}`,
Expand All @@ -1402,7 +1405,8 @@ class GithubScm extends Scm {
createTime: pullRequestInfo.data.created_at,
userProfile: pullRequestInfo.data.user.html_url,
baseBranch: pullRequestInfo.data.base.ref,
mergeable: pullRequestInfo.data.mergeable
mergeable: pullRequestInfo.data.mergeable,
prSource
};
} catch (err) {
logger.error('Failed to getPrInfo: ', err);
Expand Down
6 changes: 4 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,8 @@ jobs:
userProfile: 'https://github.com/octocat',
prBranchName: 'new-topic',
baseBranch: 'master',
mergeable: true
mergeable: true,
prSource: 'branch'
}
);
assert.calledWith(githubMock.request, 'GET /repositories/:id', { id: '111' });
Expand Down Expand Up @@ -2212,7 +2213,8 @@ jobs:
userProfile: 'https://github.com/octocat',
prBranchName: 'new-topic',
baseBranch: 'master',
mergeable: true
mergeable: true,
prSource: 'branch'
}
);
assert.notCalled(githubMock.request);
Expand Down

0 comments on commit b49641b

Please sign in to comment.