Skip to content

Commit

Permalink
feat: suggest gh pr commands to finish landing (#583)
Browse files Browse the repository at this point in the history
Also make the output easier to copy and paste.
  • Loading branch information
Alicia Lopez committed Nov 5, 2021
1 parent 8caceba commit 8f40fda
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/landing_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
runAsync, runSync, forceRunAsync
} = require('./run');
const Session = require('./session');
const { shortSha } = require('./utils');
const { shortSha, isGhAvailable } = require('./utils');

const isWindows = process.platform === 'win32';

Expand Down Expand Up @@ -416,11 +416,16 @@ class LandingSession extends Session {
}

this.cleanFiles();
cli.log('Temporary files removed');
cli.log('Temporary files removed.');
cli.log('To finish landing:');
cli.log(`1. Run \`git push ${upstream} ${branch}\``);
cli.log('1. Run: ');
cli.log(` git push ${upstream} ${branch}`);
const url = `https://github.com/${owner}/${repo}/pull/${prid}`;
cli.log(`2. Post "Landed in ${willBeLanded}" in ${url}`);
if (isGhAvailable()) {
cli.log(` gh pr comment ${prid} --body "Landed in ${willBeLanded}"`);
cli.log(` gh pr close ${prid}`);
}
}

async continue() {
Expand Down
10 changes: 10 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const which = require('which');

exports.ascending = function(a, b) {
if (a === b) return 0;
return a < b ? -1 : 1;
Expand All @@ -26,3 +28,11 @@ exports.flatten = flatten;
exports.shortSha = function shortSha(sha) {
return sha.slice(0, 12);
};

let isGhAvailableCache;
exports.isGhAvailable = function isGhAvailable() {
if (isGhAvailableCache === undefined) {
isGhAvailableCache = which.sync('gh', { nothrow: true }) !== null;
}
return isGhAvailableCache;
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"proxy-agent": "^5.0.0",
"replace-in-file": "^6.2.0",
"rimraf": "^3.0.2",
"which": "^2.0.2",
"yargs": "^16.2.0"
},
"devDependencies": {
Expand Down

0 comments on commit 8f40fda

Please sign in to comment.