diff --git a/index.js b/index.js index 5cce067..01c9f7c 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,6 @@ const config = JSON.parse(fs.readFileSync('.config.json','utf8')); const token = config.token; const repoPath = config.repo_path; const baseBranch = process.argv[2] || config.repo_branch || 'master'; -const isHotfix = !!process.argv[2]; legilimens(token, repoPath, baseBranch, (output) => { console.log(output); diff --git a/legilimens.js b/legilimens.js index f67d1a8..a4e08ca 100644 --- a/legilimens.js +++ b/legilimens.js @@ -17,7 +17,7 @@ function callGithubAPI({url, token=null, callback}) { }, callback); } -function getLastedReleaseTime(token, repoPath) { +function getLastedReleaseTime(token, repoPath, baseBranch="master") { const repoUrl = `${GITHUB_REPO_API_ROOT}${repoPath}`; return new Promise((resolve, reject) => { callGithubAPI({ @@ -27,7 +27,7 @@ function getLastedReleaseTime(token, repoPath) { switch (response.statusCode) { case 200: const lastedRelease = JSON.parse(body).filter(release => { - return ((release.target_commitish === 'master') || isHotfix) && !release.prerelease; + return release.target_commitish === baseBranch && !release.prerelease; })[0]; const lastedReleaseTime = lastedRelease ? new Date(lastedRelease.created_at) : new Date(1970,1,1); return resolve(lastedReleaseTime); @@ -77,7 +77,7 @@ function renderPullRequestsReport(pullRequests) { module.exports = (token, repoPath, baseBranch, callback) => { - getLastedReleaseTime(token, repoPath).then((lastedReleaseTime) => { + getLastedReleaseTime(token, repoPath, baseBranch).then((lastedReleaseTime) => { getClosedPullRequestsAfter(token, repoPath, lastedReleaseTime, baseBranch, callback); }); }