Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions components/git/land.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ const landOptions = {
describe: 'Automatically rebase branches with multiple commits',
default: false,
type: 'boolean'
},
fixupAll: {
describe: 'Automatically fixup all commits to the first one dismissing ' +
'other commit messages',
default: false,
type: 'boolean'
}
};

Expand Down Expand Up @@ -175,8 +181,7 @@ async function main(state, argv, cli, req, dir) {
cli.log('run `git node land --abort` before starting a new session');
return;
}
session = new LandingSession(cli, req, dir, argv.prid, argv.backport,
argv.lint, argv.autorebase);
session = new LandingSession(cli, req, dir, argv);
const metadata = await getMetadata(session.argv, argv.skipRefs, cli);
if (argv.backport) {
const split = metadata.metadata.split('\n')[0];
Expand Down
11 changes: 10 additions & 1 deletion lib/landing_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ const LINT_RESULTS = {
};

class LandingSession extends Session {
constructor(cli, req, dir, prid, backport, lint, autorebase) {
constructor(cli, req, dir,
{ prid, backport, lint, autorebase, fixupAll } = {}) {
super(cli, dir, prid);
this.req = req;
this.backport = backport;
this.lint = lint;
this.autorebase = autorebase;
this.fixupAll = fixupAll;
}

get argv() {
const args = super.argv;
args.backport = this.backport;
args.lint = this.lint;
args.autorebase = this.autorebase;
args.fixupAll = this.fixupAll;
return args;
}

Expand Down Expand Up @@ -222,6 +225,12 @@ class LandingSession extends Session {
cli.log(`Couldn't rebase ${count} commits in the PR automatically`);
this.makeRebaseSuggestion(subjects);
}
} else if (this.fixupAll) {
cli.log(`There are ${subjects.length} commits in the PR. ` +
'Attempting to fixup everything into first commit.');
await runAsync('git', ['reset', '--soft', `HEAD~${subjects.length - 1}`]);
await runAsync('git', ['commit', '--amend', '--no-edit']);
return await this.amend() && this.final();
} else {
this.makeRebaseSuggestion(subjects);
}
Expand Down