Skip to content

Commit 4efad2b

Browse files
committed
Experiment with skipping setup-git-user more often
1 parent e3e2663 commit 4efad2b

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎src/github.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,31 @@ export class GitHub {
9797
if (this.commitMode === "github-api") {
9898
return;
9999
}
100+
// Check the exact identities that Git would use for commits without
101+
// allowing Git to fall back to auto-detected values like user@hostname.
102+
// This covers explicit GIT_AUTHOR_* / GIT_COMMITTER_* env vars, local
103+
// config, and global config. A partial identity, with only a name or only
104+
// an email, does not pass this check. If either identity is missing, set
105+
// our default bot user so CLI commits don't fail or use host-derived data.
106+
const authorIdentity = await getExecOutput(
107+
"git",
108+
["-c", "user.useConfigOnly=true", "var", "GIT_AUTHOR_IDENT"],
109+
{
110+
cwd: this.cwd,
111+
ignoreReturnCode: true,
112+
},
113+
);
114+
const committerIdentity = await getExecOutput(
115+
"git",
116+
["-c", "user.useConfigOnly=true", "var", "GIT_COMMITTER_IDENT"],
117+
{
118+
cwd: this.cwd,
119+
ignoreReturnCode: true,
120+
},
121+
);
122+
if (authorIdentity.exitCode === 0 && committerIdentity.exitCode === 0) {
123+
return;
124+
}
100125
await exec("git", ["config", "user.name", `"github-actions[bot]"`], {
101126
cwd: this.cwd,
102127
});

0 commit comments

Comments
 (0)