Skip to content

Commit

Permalink
feat: allow to fixup everything into first commit with fixupAll
Browse files Browse the repository at this point in the history
  • Loading branch information
lundibundi authored and joyeecheung committed Aug 27, 2020
1 parent 1c59e44 commit 4ad4a58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 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
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

0 comments on commit 4ad4a58

Please sign in to comment.