mirror of
https://github.com/EndBug/add-and-commit.git
synced 2026-08-29 08:02:18 -05:00
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:
co-authored by
Cursor
parent
ebc24bfdec
commit
f1bb0cc0a7
Generated
+1
-1
File diff suppressed because one or more lines are too long
+15
-9
@@ -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...');
|
||||
|
||||
Reference in New Issue
Block a user