mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-11-30 09:09:57 +08:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ece24efbb4 | ||
|
|
fea6d7077e | ||
|
|
68cfeead18 | ||
|
|
f5088835af |
@@ -57,13 +57,13 @@ export function buildAllowedToolsString(
|
||||
} else {
|
||||
// When not using commit signing, add specific Bash git commands
|
||||
baseTools.push(
|
||||
"Bash(git add *)",
|
||||
"Bash(git commit *)",
|
||||
"Bash(git push *)",
|
||||
"Bash(git status *)",
|
||||
"Bash(git diff *)",
|
||||
"Bash(git log *)",
|
||||
"Bash(git rm *)",
|
||||
"Bash(git add:*)",
|
||||
"Bash(git commit:*)",
|
||||
"Bash(git push:*)",
|
||||
"Bash(git status:*)",
|
||||
"Bash(git diff:*)",
|
||||
"Bash(git log:*)",
|
||||
"Bash(git rm:*)",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ async function installClaudeCode(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
const claudeCodeVersion = "2.1.31";
|
||||
const claudeCodeVersion = "2.1.42";
|
||||
console.log(`Installing Claude Code v${claudeCodeVersion}...`);
|
||||
|
||||
for (let attempt = 1; attempt <= 3; attempt++) {
|
||||
|
||||
@@ -42,13 +42,55 @@ export async function configureGitAuth(
|
||||
await $`git config user.email "${botId}+${botName}@${noreplyDomain}"`;
|
||||
console.log(`✓ Set git user as ${botName}`);
|
||||
|
||||
// Remove the authorization header that actions/checkout sets
|
||||
// Remove the authorization header that actions/checkout sets.
|
||||
// Newer versions of actions/checkout store credentials in external config files
|
||||
// referenced via includeIf, so --unset-all on local config may not find them.
|
||||
// We clear both: local config entries and any includeIf credential files.
|
||||
console.log("Removing existing git authentication headers...");
|
||||
try {
|
||||
await $`git config --unset-all http.${GITHUB_SERVER_URL}/.extraheader`;
|
||||
console.log("✓ Removed existing authentication headers");
|
||||
} catch (e) {
|
||||
console.log("No existing authentication headers to remove");
|
||||
console.log("✓ Removed existing authentication headers from local config");
|
||||
} catch {
|
||||
console.log("No existing authentication headers in local config to remove");
|
||||
}
|
||||
|
||||
// Clear extraheader from includeIf credential config files set by actions/checkout
|
||||
try {
|
||||
const configOutput = await $`git config --list --show-origin`.text();
|
||||
const extraheaderPattern = `http.${GITHUB_SERVER_URL}/.extraheader=`;
|
||||
console.log(
|
||||
`Scanning git config origins for extraheader pattern: ${extraheaderPattern}`,
|
||||
);
|
||||
let foundExternalEntries = false;
|
||||
for (const line of configOutput.split("\n")) {
|
||||
if (!line.includes(extraheaderPattern)) continue;
|
||||
// Format: "file:<path>\t<key>=<value>"
|
||||
const match = line.match(/^file:(.+?)\t/);
|
||||
if (!match) {
|
||||
console.log(
|
||||
`Found extraheader but could not parse origin: ${line.substring(0, 80)}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
const configFile = match[1]!;
|
||||
// Skip the local .git/config — we already handled that above
|
||||
if (configFile.endsWith("/.git/config")) {
|
||||
console.log("Skipping .git/config (already handled)");
|
||||
continue;
|
||||
}
|
||||
foundExternalEntries = true;
|
||||
try {
|
||||
await $`git config --file ${configFile} --unset-all http.${GITHUB_SERVER_URL}/.extraheader`;
|
||||
console.log(`✓ Removed authentication headers from ${configFile}`);
|
||||
} catch {
|
||||
console.log(`Could not unset extraheader from ${configFile}`);
|
||||
}
|
||||
}
|
||||
if (!foundExternalEntries) {
|
||||
console.log("No external credential config files found");
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`Could not enumerate git config origins: ${error}`);
|
||||
}
|
||||
|
||||
// Update the remote URL to include the token for authentication
|
||||
|
||||
@@ -135,13 +135,13 @@ export async function prepareTagMode({
|
||||
// SSH signing still uses git CLI, just with signing enabled
|
||||
if (!useApiCommitSigning) {
|
||||
tagModeTools.push(
|
||||
"Bash(git add *)",
|
||||
"Bash(git commit *)",
|
||||
"Bash(git push *)",
|
||||
"Bash(git status *)",
|
||||
"Bash(git diff *)",
|
||||
"Bash(git log *)",
|
||||
"Bash(git rm *)",
|
||||
"Bash(git add:*)",
|
||||
"Bash(git commit:*)",
|
||||
"Bash(git push:*)",
|
||||
"Bash(git status:*)",
|
||||
"Bash(git diff:*)",
|
||||
"Bash(git log:*)",
|
||||
"Bash(git rm:*)",
|
||||
);
|
||||
} else {
|
||||
// When using API commit signing, use MCP file ops tools
|
||||
|
||||
+13
-13
@@ -894,9 +894,9 @@ describe("buildAllowedToolsString", () => {
|
||||
expect(result).toContain("Write");
|
||||
|
||||
// Default is no commit signing, so should have specific Bash git commands
|
||||
expect(result).toContain("Bash(git add *)");
|
||||
expect(result).toContain("Bash(git commit *)");
|
||||
expect(result).toContain("Bash(git push *)");
|
||||
expect(result).toContain("Bash(git add:*)");
|
||||
expect(result).toContain("Bash(git commit:*)");
|
||||
expect(result).toContain("Bash(git push:*)");
|
||||
expect(result).toContain("mcp__github_comment__update_claude_comment");
|
||||
|
||||
// Should not have commit signing tools
|
||||
@@ -916,8 +916,8 @@ describe("buildAllowedToolsString", () => {
|
||||
expect(result).toContain("Write");
|
||||
|
||||
// Should have specific Bash git commands for non-signing mode
|
||||
expect(result).toContain("Bash(git add *)");
|
||||
expect(result).toContain("Bash(git commit *)");
|
||||
expect(result).toContain("Bash(git add:*)");
|
||||
expect(result).toContain("Bash(git commit:*)");
|
||||
expect(result).toContain("mcp__github_comment__update_claude_comment");
|
||||
|
||||
// Should not have commit signing tools
|
||||
@@ -1009,13 +1009,13 @@ describe("buildAllowedToolsString", () => {
|
||||
expect(result).toContain("Write");
|
||||
|
||||
// Specific Bash git commands should be included
|
||||
expect(result).toContain("Bash(git add *)");
|
||||
expect(result).toContain("Bash(git commit *)");
|
||||
expect(result).toContain("Bash(git push *)");
|
||||
expect(result).toContain("Bash(git status *)");
|
||||
expect(result).toContain("Bash(git diff *)");
|
||||
expect(result).toContain("Bash(git log *)");
|
||||
expect(result).toContain("Bash(git rm *)");
|
||||
expect(result).toContain("Bash(git add:*)");
|
||||
expect(result).toContain("Bash(git commit:*)");
|
||||
expect(result).toContain("Bash(git push:*)");
|
||||
expect(result).toContain("Bash(git status:*)");
|
||||
expect(result).toContain("Bash(git diff:*)");
|
||||
expect(result).toContain("Bash(git log:*)");
|
||||
expect(result).toContain("Bash(git rm:*)");
|
||||
|
||||
// Comment tool from minimal server should be included
|
||||
expect(result).toContain("mcp__github_comment__update_claude_comment");
|
||||
@@ -1031,7 +1031,7 @@ describe("buildAllowedToolsString", () => {
|
||||
|
||||
// Base tools should be present
|
||||
expect(result).toContain("Edit");
|
||||
expect(result).toContain("Bash(git add *)");
|
||||
expect(result).toContain("Bash(git add:*)");
|
||||
|
||||
// Custom tools should be included
|
||||
expect(result).toContain("CustomTool1");
|
||||
|
||||
Reference in New Issue
Block a user