Skip to content

Commit d8ae7c7

Browse files
authored
feat(git-node): add support for amend! commits (#710)
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.
1 parent 015bf20 commit d8ae7c7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/landing_session.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ export default class LandingSession extends Session {
119119
const commitInfo = { base, head, shas: commitShas };
120120
this.saveCommitInfo(commitInfo);
121121

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

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

158157
const squashes = subjects.filter(
159-
line => line.includes('fixup!') || line.includes('squash!'));
158+
line => line.includes('fixup!') || line.includes('squash!') || line.includes('amend!'));
160159

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

0 commit comments

Comments
 (0)