Skip to content

Commit 947ec98

Browse files
committed
fixup! chore(git-node): avoid dealing with patch files for landing
1 parent 3d4537a commit 947ec98

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

lib/landing_session.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ class LandingSession extends Session {
8787
await runAsync('git', [
8888
'fetch', `https://github.com/${owner}/${repo}.git`,
8989
`refs/pull/${prid}/merge`]);
90-
const [base, head] = (await runAsync('git', [
91-
'rev-parse', 'FETCH_HEAD^1', 'FETCH_HEAD^2'], { captureStdout: true }))
92-
.split('\n');
93-
const commitShas = (await runAsync('git', [
94-
'rev-list', `${base}..${head}`], { captureStdout: true }))
95-
.trim().split('\n');
90+
// We fetched the commit that would result if we used `git merge`.
91+
// ^1 and ^2 refer to the PR base and the PR head, respectively.
92+
const [base, head] = await runAsync('git',
93+
['rev-parse', 'FETCH_HEAD^1', 'FETCH_HEAD^2'],
94+
{ captureStdout: 'lines' });
95+
const commitShas = await runAsync('git',
96+
['rev-list', `${base}..${head}`],
97+
{ captureStdout: 'lines' });
9698
cli.stopSpinner(`Fetched commits as ${shortSha(base)}..${shortSha(head)}`);
9799
cli.separator();
98100

@@ -188,9 +190,9 @@ class LandingSession extends Session {
188190

189191
async tryCompleteLanding(commitInfo) {
190192
const { cli } = this;
191-
const subjects = (await runAsync('git',
193+
const subjects = await runAsync('git',
192194
['log', '--pretty=format:%s', `${commitInfo.base}..${commitInfo.head}`],
193-
{ captureStdout: true })).trim().split('\n');
195+
{ captureStdout: 'lines' });
194196

195197
if (commitInfo.shas.length === 1) {
196198
const shouldAmend = await cli.prompt(

lib/run.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ function runAsyncBase(cmd, args, {
3030
err.messageOnly = true;
3131
return reject(err);
3232
}
33+
if (captureStdout === 'lines') {
34+
stdout = stdout.split(/\r?\n/g);
35+
if (stdout[stdout.length - 1] === '') stdout.pop();
36+
}
3337
return resolve(stdout);
3438
});
3539
});

0 commit comments

Comments
 (0)