Skip to content

Commit

Permalink
fixup! chore(git-node): avoid dealing with patch files for landing
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Sep 7, 2020
1 parent 3d4537a commit 947ec98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/landing_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,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();

Expand Down Expand Up @@ -188,9 +190,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(
Expand Down
4 changes: 4 additions & 0 deletions lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand Down

0 comments on commit 947ec98

Please sign in to comment.