Skip to content

Commit f1bb0cc

Browse files
EndBugcursoragent
andauthored
fix: do not report committed=true for empty commit SHA (#757)
* fix: do not report committed=true for empty commit SHA simple-git can resolve successfully with an empty commit hash when no commit was actually created; keep the committed output accurate. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: stop tagging/pushing after empty commit SHA Let empty-SHA failures reject so the outer catch stops the action instead of continuing after setFailed. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent ebc24bf commit f1bb0cc

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

‎lib/index.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/main.ts‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,21 @@ core.info(`Running in ${baseDir}`);
126126
} else core.info('> Not pulling from repo.');
127127

128128
core.info('> Creating commit...');
129-
await git
130-
.commit(getInput('message'), matchGitArgs(getInput('commit') || ''))
131-
.then(async data => {
132-
log(undefined, data);
133-
setOutput('committed', 'true');
134-
setOutput('commit_long_sha', data.commit);
135-
setOutput('commit_sha', data.commit.substring(0, 7));
136-
})
137-
.catch(err => core.setFailed(err));
129+
const data = await git.commit(
130+
getInput('message'),
131+
matchGitArgs(getInput('commit') || ''),
132+
);
133+
log(undefined, data);
134+
// simple-git can resolve with an empty SHA when no commit was created
135+
// (e.g. nothing left to commit). Do not report a false success.
136+
if (!data.commit) {
137+
throw new Error(
138+
'Commit did not produce a SHA; refusing to report committed=true.',
139+
);
140+
}
141+
setOutput('committed', 'true');
142+
setOutput('commit_long_sha', data.commit);
143+
setOutput('commit_sha', data.commit.substring(0, 7));
138144

139145
if (getInput('tag')) {
140146
core.info('> Tagging commit...');

0 commit comments

Comments
 (0)