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>
This commit is contained in:
Federico Grandi
2026-08-08 22:21:22 +00:00
committed by GitHub
co-authored by Cursor
parent ebc24bfdec
commit f1bb0cc0a7
2 changed files with 16 additions and 10 deletions
Generated
+1 -1
View File
File diff suppressed because one or more lines are too long
+15 -9
View File
@@ -126,15 +126,21 @@ core.info(`Running in ${baseDir}`);
} else core.info('> Not pulling from repo.');
core.info('> Creating commit...');
await git
.commit(getInput('message'), matchGitArgs(getInput('commit') || ''))
.then(async data => {
log(undefined, data);
setOutput('committed', 'true');
setOutput('commit_long_sha', data.commit);
setOutput('commit_sha', data.commit.substring(0, 7));
})
.catch(err => core.setFailed(err));
const data = await git.commit(
getInput('message'),
matchGitArgs(getInput('commit') || ''),
);
log(undefined, data);
// simple-git can resolve with an empty SHA when no commit was created
// (e.g. nothing left to commit). Do not report a false success.
if (!data.commit) {
throw new Error(
'Commit did not produce a SHA; refusing to report committed=true.',
);
}
setOutput('committed', 'true');
setOutput('commit_long_sha', data.commit);
setOutput('commit_sha', data.commit.substring(0, 7));
if (getInput('tag')) {
core.info('> Tagging commit...');