diff --git a/lib/landing_session.js b/lib/landing_session.js index 37079c5e..e458d600 100644 --- a/lib/landing_session.js +++ b/lib/landing_session.js @@ -84,12 +84,14 @@ class LandingSession extends Session { await runAsync('git', [ 'fetch', `https://github.com/${owner}/${repo}.git`, `refs/pull/${prid}/merge`]); - const [base, head] = (await runAsync('git', [ - 'rev-parse', 'FETCH_HEAD^1', 'FETCH_HEAD^2'], { captureStdout: true })) - .split('\n'); - const commitShas = (await runAsync('git', [ - 'rev-list', `${base}..${head}`], { captureStdout: true })) - .trim().split('\n'); + // We fetched the commit that would result if we used `git merge`. + // ^1 and ^2 refer to the PR base and the PR head, respectively. + const [base, head] = await runAsync('git', + ['rev-parse', 'FETCH_HEAD^1', 'FETCH_HEAD^2'], + { captureStdout: 'lines' }); + const commitShas = await runAsync('git', + ['rev-list', `${base}..${head}`], + { captureStdout: 'lines' }); cli.stopSpinner(`Fetched commits as ${shortSha(base)}..${shortSha(head)}`); cli.separator(); @@ -185,9 +187,9 @@ class LandingSession extends Session { async tryCompleteLanding(commitInfo) { const { cli } = this; - const subjects = (await runAsync('git', + const subjects = await runAsync('git', ['log', '--pretty=format:%s', `${commitInfo.base}..${commitInfo.head}`], - { captureStdout: true })).trim().split('\n'); + { captureStdout: 'lines' }); if (commitInfo.shas.length === 1) { const shouldAmend = await cli.prompt( diff --git a/lib/run.js b/lib/run.js index 00e068bf..12477907 100644 --- a/lib/run.js +++ b/lib/run.js @@ -30,6 +30,10 @@ function runAsyncBase(cmd, args, { err.messageOnly = true; return reject(err); } + if (captureStdout === 'lines') { + stdout = stdout.split(/\r?\n/g); + if (stdout[stdout.length - 1] === '') stdout.pop(); + } return resolve(stdout); }); });