Skip to content

Commit

Permalink
feat(git-node): add support for amend! commits (#710)
Browse files Browse the repository at this point in the history
Commits made using `git commit --fixup=reword:HEAD` are empty commits
that lets the user change the commit message without needing to
force-push the PR branch. With this commit, those are
still ignored when using `--fixupAll` CLI flag.
  • Loading branch information
aduh95 authored Jun 26, 2023
1 parent 015bf20 commit d8ae7c7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/landing_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ export default class LandingSession extends Session {
const commitInfo = { base, head, shas: commitShas };
this.saveCommitInfo(commitInfo);

const allowEmptyCommits = this.fixupAll ? ['--allow-empty'] : [];
try {
await forceRunAsync('git',
['cherry-pick', ...allowEmptyCommits, ...this.gpgSign, `${base}..${head}`],
['cherry-pick', '--allow-empty', ...this.gpgSign, `${base}..${head}`],
{ ignoreFailure: false });
} catch (ex) {
cli.error('Failed to apply patches');
Expand Down Expand Up @@ -152,11 +151,11 @@ export default class LandingSession extends Session {

getRebaseSuggestion(subjects) {
const { upstream, branch } = this;
let command = `git rebase ${upstream}/${branch} -i`;
let command = `git rebase ${upstream}/${branch} --no-keep-empty -i`;
command += ' -x "git node land --amend"';

const squashes = subjects.filter(
line => line.includes('fixup!') || line.includes('squash!'));
line => line.includes('fixup!') || line.includes('squash!') || line.includes('amend!'));

if (squashes.length !== 0) {
command += ' --autosquash';
Expand Down Expand Up @@ -233,7 +232,8 @@ export default class LandingSession extends Session {
const msgAmend = `-x "git node land --amend ${assumeYes}"`;
try {
await forceRunAsync('git',
['rebase', ...this.gpgSign, `${upstream}/${branch}`, '-i', '--autosquash', msgAmend],
['rebase', ...this.gpgSign, `${upstream}/${branch}`,
'--no-keep-empty', '-i', '--autosquash', msgAmend],
{
ignoreFailure: false,
spawnArgs: {
Expand Down

0 comments on commit d8ae7c7

Please sign in to comment.