@@ -51379,6 +51379,16 @@ class ProjectRepository {
5137951379 const { data: user } = await octokit.rest.users.getAuthenticated();
5138051380 return user.login;
5138151381 };
51382+ /** Name and email of the token user, for git commit author (e.g. bugbot autofix). */
51383+ this.getTokenUserDetails = async (token) => {
51384+ const octokit = github.getOctokit(token);
51385+ const { data: user } = await octokit.rest.users.getAuthenticated();
51386+ const name = (user.name ?? user.login ?? "GitHub Action").trim() || "GitHub Action";
51387+ const email = (typeof user.email === "string" && user.email.trim().length > 0)
51388+ ? user.email.trim()
51389+ : `${user.login}@users.noreply.github.com`;
51390+ return { name, email };
51391+ };
5138251392 this.findTag = async (owner, repo, tag, token) => {
5138351393 const octokit = github.getOctokit(token);
5138451394 try {
@@ -53743,6 +53753,7 @@ exports.SingleActionUseCase = SingleActionUseCase;
5374353753/**
5374453754 * Runs verify commands and then git add/commit/push for bugbot autofix.
5374553755 * Uses @actions/exec; intended to run in the GitHub Action runner where the repo is checked out.
53756+ * Configures git user.name and user.email from the token user so the commit has a valid author.
5374653757 */
5374753758var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5374853759 if (k2 === undefined) k2 = k;
@@ -53780,6 +53791,7 @@ var __importStar = (this && this.__importStar) || (function () {
5378053791Object.defineProperty(exports, "__esModule", ({ value: true }));
5378153792exports.runBugbotAutofixCommitAndPush = runBugbotAutofixCommitAndPush;
5378253793const exec = __importStar(__nccwpck_require__(1514));
53794+ const project_repository_1 = __nccwpck_require__(7917);
5378353795const logger_1 = __nccwpck_require__(8836);
5378453796/**
5378553797 * Optionally check out the branch (when event is issue_comment and we resolved the branch from an open PR).
@@ -53867,6 +53879,11 @@ async function runBugbotAutofixCommitAndPush(execution, options) {
5386753879 return { success: true, committed: false };
5386853880 }
5386953881 try {
53882+ const projectRepository = new project_repository_1.ProjectRepository();
53883+ const { name, email } = await projectRepository.getTokenUserDetails(execution.tokens.token);
53884+ await exec.exec("git", ["config", "user.name", name]);
53885+ await exec.exec("git", ["config", "user.email", email]);
53886+ (0, logger_1.logDebugInfo)(`Git author set to ${name} <${email}>.`);
5387053887 await exec.exec("git", ["add", "-A"]);
5387153888 const commitMessage = "fix: bugbot autofix - resolve reported findings";
5387253889 await exec.exec("git", ["commit", "-m", commitMessage]);
0 commit comments