Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --lite option for git-node land (makes it usable with repos other than nodejs/node) #546

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions components/git/land.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ const landOptions = {
describe: 'Query Jenkins CI results when checking the PR',
default: true,
type: 'boolean'
},
lite: {
type: 'boolean',
default: false,
describe: 'Eliminates some requirements, such as configuring a Jenkins ' +
'API token, and parsing TSC members and Collaborators from README.md. ' +
'Suitable for using "git-node land" in repositories other than nodejs/node.'
}
};

Expand Down
2 changes: 1 addition & 1 deletion components/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const fs = require('fs');
async function getMetadata(argv, skipRefs, cli) {
const credentials = await auth({
github: true,
jenkins: true
jenkins: !argv.lite
});
const request = new Request(credentials);

Expand Down
61 changes: 37 additions & 24 deletions docs/git-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,47 @@ git-node land [prid|options]
Manage the current landing session or start a new one for a pull request

Positionals:
prid, options ID of the Pull Request [number]
prid, options ID or URL of the Pull Request

Options:
--version Show version number [boolean]
--help Show help [boolean]
--apply Apply a patch with the given PR id [number]
--amend Amend the current commit [boolean]
--continue, -c Continue the landing session [boolean]
--final Verify the landed PR and clean up [boolean]
--abort Abort the current landing session [boolean]
--backport Land a backport PR on a staging branch [boolean]
--yes Assume "yes" as answer to all prompts and run
non-interactively. If an undesirable situation occurs, such as
a pull request or commit check fails, then git node land will
abort. [boolean] [default: false]
--skipRefs Prevent Fixes and Refs information from being added to commit
metadata [boolean] [default: false]

--version Show version number [boolean]
--help Show help [boolean]
--yes Assume "yes" as answer to all prompts and run
non-interactively. If an undesirable situation occurs, such
as a pull request or commit check fails, then git node land
will abort. [boolean] [default: false]
--skipRefs Prevent adding Fixes and Refs information to commit metadata
[boolean] [default: false]
--lint Run linter while landing commits [boolean] [default: false]
--checkCI Query Jenkins CI results when checking the PR
[boolean] [default: true]
--lite Eliminates some requirements, such as configuring a Jenkins
API token, and parsing TSC members and Collaborators from
README.md. Suitable for using "git-node land" in
repositories other than nodejs/node.
[boolean] [default: false]
--apply Apply a patch with the given PR id [number]
--amend Amend the current commit [boolean]
-c, --continue Continue the landing session [boolean]
--final Verify the landed PR and clean up [boolean]
--abort Abort the current landing session [boolean]
--backport Land a backport PR onto a staging branch
[boolean] [default: false]
--autorebase Automatically rebase branches with multiple commits
[boolean] [default: false]
--fixupAll Automatically fixup all commits to the first one dismissing
other commit messages [boolean] [default: false]

Examples:
git node land 12344 Land https://github.com/nodejs/node/pull/12344
in the current directory
git node land --abort Abort the current session
git node land --amend Append metadata to the current commit message
git node land --final Verify the landed PR and clean up
git node land --continue Continue the current landing session
git node land --backport 30072 Land https://github.com/nodejs/node/pull/30072
as a backport in the current directory
git node land https://github.com/nodejs/ Land https://github.com/nodejs/node/
node/pull/12344 pull/12344 in the current directory
git node land 12344 Land https://github.com/nodejs/node/
pull/12344 in the current directory
git node land --abort Abort the current session
git node land --amend Append metadata to the current
commit message
git node land --final Verify the landed PR and clean up
git node land --continue Continue the current landing session
```

<a id="git-node-land-prerequisites"></a>
Expand Down
4 changes: 3 additions & 1 deletion lib/landing_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const LINT_RESULTS = {

class LandingSession extends Session {
constructor(cli, req, dir,
{ prid, backport, lint, autorebase, fixupAll, checkCI } = {}) {
{ prid, backport, lint, autorebase, fixupAll, checkCI, lite } = {}) {
super(cli, dir, prid);
this.req = req;
this.backport = backport;
Expand All @@ -32,6 +32,7 @@ class LandingSession extends Session {
this.fixupAll = fixupAll;
this.expectedCommitShas = [];
this.checkCI = !!checkCI;
this.lite = !!lite;
}

get argv() {
Expand All @@ -40,6 +41,7 @@ class LandingSession extends Session {
args.lint = this.lint;
args.autorebase = this.autorebase;
args.fixupAll = this.fixupAll;
args.lite = this.lite;
return args;
}

Expand Down
11 changes: 8 additions & 3 deletions lib/pr_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,16 @@ class PRData {
async getAll(argv) {
const { prStr } = this;
this.cli.startSpinner(`Loading data for ${prStr}`);
await Promise.all([
this.getCollaborators(),
const listOfPromises = [
this.getThreadData(),
this.getCommits()
]).then(() => {
];
if (!this.argv.lite) {
// Parse TSC members/Collaborators, except in "lite" mode.
listOfPromises.unshift(this.getCollaborators());
}

await Promise.all(listOfPromises).then(() => {
this.cli.stopSpinner(`Done loading data for ${prStr}`);
});
this.analyzeReviewers();
Expand Down
3 changes: 2 additions & 1 deletion lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class Session {
updateDeprecations: this.updateDeprecations,
ciType: this.ciType,
prid: this.prid,
checkCI: this.checkCI
checkCI: this.checkCI,
lite: this.lite
};
}

Expand Down