Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,31 @@ export class GitHub {
if (this.commitMode === "github-api") {
return;
}
// Check the exact identities that Git would use for commits without
// allowing Git to fall back to auto-detected values like user@hostname.
// This covers explicit GIT_AUTHOR_* / GIT_COMMITTER_* env vars, local
// config, and global config. A partial identity, with only a name or only
// an email, does not pass this check. If either identity is missing, set
// our default bot user so CLI commits don't fail or use host-derived data.
const authorIdentity = await getExecOutput(
"git",
["-c", "user.useConfigOnly=true", "var", "GIT_AUTHOR_IDENT"],
{
cwd: this.cwd,
ignoreReturnCode: true,
},
);
const committerIdentity = await getExecOutput(
"git",
["-c", "user.useConfigOnly=true", "var", "GIT_COMMITTER_IDENT"],
{
cwd: this.cwd,
ignoreReturnCode: true,
},
);
if (authorIdentity.exitCode === 0 && committerIdentity.exitCode === 0) {
return;
}
await exec("git", ["config", "user.name", `"github-actions[bot]"`], {
cwd: this.cwd,
});
Expand Down