From b49641b170c76d11d66130cbf8fbf5d880f2fdc4 Mon Sep 17 00:00:00 2001 From: Keisuke Kumada Date: Sat, 18 Apr 2020 04:22:30 +0900 Subject: [PATCH] fix(2029): Add prSource to prInfo return value (#154) --- index.js | 6 +++++- test/index.test.js | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 33a1864..7ff602d 100644 --- a/index.js +++ b/index.js @@ -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}`, @@ -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); diff --git a/test/index.test.js b/test/index.test.js index cd2d437..a5c2c5d 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -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' }); @@ -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);