fix: configure git identity before conflict merge
This commit is contained in:
1 parent
c2f39d452b
commit
d36668c5c7
2 files changed
+19
-11
No files matched your search
@@ -124,6 +124,18 @@ export async function resolvePullRequestConflicts(
|
||||
return false;
|
||||
}
|
||||
|
||||
await runCommand("git", ["config", "user.name", config.botName], worktree, gitEnv);
|
||||
await runCommand(
|
||||
"git",
|
||||
[
|
||||
"config",
|
||||
"user.email",
|
||||
`${config.githubAppId ?? "41898282"}+${config.botName}@users.noreply.github.com`
|
||||
],
|
||||
worktree,
|
||||
gitEnv
|
||||
);
|
||||
|
||||
await runCommand(
|
||||
"git",
|
||||
["fetch", "--no-tags", "origin", `${params.baseBranch}:refs/remotes/origin/ghbot-base`],
|
||||
@@ -241,17 +253,6 @@ export async function resolvePullRequestConflicts(
|
||||
return false;
|
||||
}
|
||||
|
||||
await runCommand("git", ["config", "user.name", config.botName], worktree, gitEnv);
|
||||
await runCommand(
|
||||
"git",
|
||||
[
|
||||
"config",
|
||||
"user.email",
|
||||
`${config.githubAppId ?? "41898282"}+${config.botName}@users.noreply.github.com`
|
||||
],
|
||||
worktree,
|
||||
gitEnv
|
||||
);
|
||||
await runCommand(
|
||||
"git",
|
||||
["commit", "-m", `fix: resolve conflicts for PR #${params.pullNumber}`],
|
||||
@@ -310,6 +311,9 @@ export function describeConflictResolutionFailure(error: unknown): string {
|
||||
if (message.includes("refusing to merge unrelated histories") || message.includes("shallow")) {
|
||||
return "Conflict repair could not prepare the merge because the PR checkout did not contain enough Git history. No commit was pushed.";
|
||||
}
|
||||
if (message.includes("committer identity unknown") || message.includes("empty ident name")) {
|
||||
return "Conflict repair could not start the merge because the temporary Git worktree had no bot committer identity. No commit was pushed.";
|
||||
}
|
||||
if (
|
||||
message.includes("write access to repository not granted") ||
|
||||
message.includes("permission denied") ||
|
||||
|
||||
@@ -42,6 +42,10 @@ test("conflict failures are actionable without exposing raw command output", ()
|
||||
describeConflictResolutionFailure(new Error("remote: Write access to repository not granted")),
|
||||
/Allow edits from maintainers/
|
||||
);
|
||||
assert.match(
|
||||
describeConflictResolutionFailure(new Error("Committer identity unknown")),
|
||||
/no bot committer identity/
|
||||
);
|
||||
assert.match(
|
||||
describeConflictResolutionFailure(new Error("rejected: stale info")),
|
||||
/Run \/conflict again/
|
||||
|
||||
Reference in new issue
Block a user