Compare commits

..

10 Commits

Author SHA1 Message Date
woehrer12
1fd3bbc91b chore: claude-code to v0.0.24 (#3) 2025-07-06 22:48:46 +01:00
Mark Wylde
a8399fe052 Merge pull request #2 from zinglax/shallow-fetch
Adding --depth=1 to fetchs to save time for large repos
2025-06-06 08:54:50 +01:00
zinglax
f640f38102 Adding --depth=1 to fetchs to save time
See https://github.com/anthropics/claude-code-action/issues/52
2025-06-04 09:44:05 -04:00
Mark Wylde
54147e92b6 fix: follow commit convention 2025-06-01 12:21:05 +01:00
Mark Wylde
42d3e56b56 fix: encourage use of mcp__gitea__list_branches 2025-05-31 13:54:12 +01:00
Mark Wylde
2c9043d65f fix: prompt 2025-05-31 13:46:05 +01:00
Mark Wylde
957f0ddc6f fix: encourage tool use over link 2025-05-31 13:35:56 +01:00
Mark Wylde
4005d690a8 fix: syntax 2025-05-31 13:30:39 +01:00
Mark Wylde
319e236b21 chore: remove stuff from prompt 2025-05-31 13:23:04 +01:00
Mark Wylde
b4448a4e51 fix: explain how to create pull request 2025-05-31 13:17:39 +01:00
4 changed files with 12 additions and 38 deletions

View File

@@ -113,7 +113,7 @@ runs:
- name: Run Claude Code - name: Run Claude Code
id: claude-code id: claude-code
if: steps.prepare.outputs.contains_trigger == 'true' if: steps.prepare.outputs.contains_trigger == 'true'
uses: anthropics/claude-code-base-action@c8e31bd52d9a149b3f8309d7978c6edaa282688d # v0.0.8 uses: anthropics/claude-code-base-action@v0.0.24
with: with:
prompt_file: /tmp/claude-prompts/claude-prompt.txt prompt_file: /tmp/claude-prompts/claude-prompt.txt
allowed_tools: ${{ env.ALLOWED_TOOLS }} allowed_tools: ${{ env.ALLOWED_TOOLS }}

View File

@@ -536,7 +536,7 @@ ${
? ` ? `
4. Check for Existing Branch (for issues and closed PRs): 4. Check for Existing Branch (for issues and closed PRs):
- Before implementing changes, check if there's already a claude branch for this ${eventData.isPR ? "PR" : "issue"}. - Before implementing changes, check if there's already a claude branch for this ${eventData.isPR ? "PR" : "issue"}.
- Use Bash to run \`git branch -r | grep "claude/${eventData.isPR ? "pr" : "issue"}-${eventData.isPR ? eventData.prNumber : eventData.issueNumber}"\` to search for existing branches. - Use the mcp__gitea__list_branches tool to list branches.
- If found, use mcp__local_git_ops__checkout_branch to switch to the existing branch (set fetch_remote=true). - If found, use mcp__local_git_ops__checkout_branch to switch to the existing branch (set fetch_remote=true).
- If not found, you'll create a new branch when making changes (see Execute Actions section). - If not found, you'll create a new branch when making changes (see Execute Actions section).
- Mark this todo as complete by checking the box. - Mark this todo as complete by checking the box.
@@ -566,29 +566,19 @@ ${
eventData.isPR && !eventData.claudeBranch eventData.isPR && !eventData.claudeBranch
? ` ? `
- Commit changes using mcp__local_git_ops__commit_files to the existing branch (works for both new and existing files). - Commit changes using mcp__local_git_ops__commit_files to the existing branch (works for both new and existing files).
- Make sure commits follow the same convention as other commits in the repository.
- Use mcp__local_git_ops__commit_files to commit files atomically in a single commit (supports single or multiple files). - Use mcp__local_git_ops__commit_files to commit files atomically in a single commit (supports single or multiple files).
- CRITICAL: After committing, you MUST push the branch to the remote repository using mcp__local_git_ops__push_branch - CRITICAL: After committing, you MUST push the branch to the remote repository using mcp__local_git_ops__push_branch
- After pushing, you MUST create a PR using mcp__local_git_ops__create_pull_request.
- When pushing changes with this tool and TRIGGER_USERNAME is not "Unknown", include a "Co-authored-by: ${context.triggerUsername} <${context.triggerUsername}@users.noreply.local>" line in the commit message.` - When pushing changes with this tool and TRIGGER_USERNAME is not "Unknown", include a "Co-authored-by: ${context.triggerUsername} <${context.triggerUsername}@users.noreply.local>" line in the commit message.`
: eventData.claudeBranch : eventData.claudeBranch
? ` ? `
- You are already on the correct branch (${eventData.claudeBranch}). Do not create a new branch. - You are already on the correct branch (${eventData.claudeBranch}). Do not create a new branch.
- Commit changes using mcp__local_git_ops__commit_files (works for both new and existing files) - Commit changes using mcp__local_git_ops__commit_files (works for both new and existing files)
- Make sure commits follow the same convention as other commits in the repository.
- Use mcp__local_git_ops__commit_files to commit files atomically in a single commit (supports single or multiple files). - Use mcp__local_git_ops__commit_files to commit files atomically in a single commit (supports single or multiple files).
- CRITICAL: After committing, you MUST push the branch to the remote repository using mcp__local_git_ops__push_branch - CRITICAL: After committing, you MUST push the branch to the remote repository using mcp__local_git_ops__push_branch
- When pushing changes and TRIGGER_USERNAME is not "Unknown", include a "Co-authored-by: ${context.triggerUsername} <${context.triggerUsername}@users.noreply.local>" line in the commit message. `
- Provide a URL to create a PR manually in this format:
[Create a PR](${GITEA_SERVER_URL}/${context.repository}/compare/${eventData.baseBranch}...<branch-name>?quick_pull=1&title=<url-encoded-title>&body=<url-encoded-body>)
- IMPORTANT: Use THREE dots (...) between branch names, not two (..)
Example: ${GITEA_SERVER_URL}/${context.repository}/compare/main...feature-branch (correct)
NOT: ${GITEA_SERVER_URL}/${context.repository}/compare/main..feature-branch (incorrect)
- IMPORTANT: Ensure all URL parameters are properly encoded - spaces should be encoded as %20, not left as spaces
Example: Instead of "fix: update welcome message", use "fix%3A%20update%20welcome%20message"
- The target-branch should be '${eventData.baseBranch}'.
- The branch-name is the current branch: ${eventData.claudeBranch}
- The body should include:
- A clear description of the changes
- Reference to the original ${eventData.isPR ? "PR" : "issue"}
- Just include the markdown link with text "Create a PR" - do not add explanatory text before it like "You can create a PR using this link"`
: ` : `
- IMPORTANT: You are currently on the base branch (${eventData.baseBranch}). Before making changes, you should first check if there's already an existing claude branch for this ${eventData.isPR ? "PR" : "issue"}. - IMPORTANT: You are currently on the base branch (${eventData.baseBranch}). Before making changes, you should first check if there's already an existing claude branch for this ${eventData.isPR ? "PR" : "issue"}.
- FIRST: Use Bash to run \`git branch -r | grep "claude/${eventData.isPR ? "pr" : "issue"}-${eventData.isPR ? eventData.prNumber : eventData.issueNumber}"\` to check for existing branches. - FIRST: Use Bash to run \`git branch -r | grep "claude/${eventData.isPR ? "pr" : "issue"}-${eventData.isPR ? eventData.prNumber : eventData.issueNumber}"\` to check for existing branches.
@@ -602,20 +592,8 @@ ${
- After being on the correct branch (existing or new), commit changes using mcp__local_git_ops__commit_files (works for both new and existing files) - After being on the correct branch (existing or new), commit changes using mcp__local_git_ops__commit_files (works for both new and existing files)
- Use mcp__local_git_ops__commit_files to commit files atomically in a single commit (supports single or multiple files). - Use mcp__local_git_ops__commit_files to commit files atomically in a single commit (supports single or multiple files).
- CRITICAL: After committing, you MUST push the branch to the remote repository using mcp__local_git_ops__push_branch - CRITICAL: After committing, you MUST push the branch to the remote repository using mcp__local_git_ops__push_branch
- When pushing changes and TRIGGER_USERNAME is not "Unknown", include a "Co-authored-by: ${context.triggerUsername} <${context.triggerUsername}@users.noreply.local>" line in the commit message. - After pushing, you should create a PR using mcp__local_git_ops__create_pull_request unless one already exists for that branch.
- Provide a URL to create a PR manually in this format: `
[Create a PR](${GITEA_SERVER_URL}/${context.repository}/compare/${eventData.baseBranch}...<branch-name>?quick_pull=1&title=<url-encoded-title>&body=<url-encoded-body>)
- IMPORTANT: Use THREE dots (...) between branch names, not two (..)
Example: ${GITEA_SERVER_URL}/${context.repository}/compare/main...feature-branch (correct)
NOT: ${GITEA_SERVER_URL}/${context.repository}/compare/main..feature-branch (incorrect)
- IMPORTANT: Ensure all URL parameters are properly encoded - spaces should be encoded as %20, not left as spaces
Example: Instead of "fix: update welcome message", use "fix%3A%20update%20welcome%20message"
- The target-branch should be '${eventData.baseBranch}'.
- The branch-name is your created branch name
- The body should include:
- A clear description of the changes
- Reference to the original ${eventData.isPR ? "PR" : "issue"}
- Just include the markdown link with text "Create a PR" - do not add explanatory text before it like "You can create a PR using this link"`
} }
C. For Complex Changes: C. For Complex Changes:
@@ -632,7 +610,7 @@ ${!eventData.isPR || !eventData.claudeBranch ? `6. Final Update:` : `5. Final Up
- When all todos are completed, remove the spinner and add a brief summary of what was accomplished, and what was not done. - When all todos are completed, remove the spinner and add a brief summary of what was accomplished, and what was not done.
- Note: If you see previous Claude comments with headers like "**Claude finished @user's task**" followed by "---", do not include this in your comment. The system adds this automatically. - Note: If you see previous Claude comments with headers like "**Claude finished @user's task**" followed by "---", do not include this in your comment. The system adds this automatically.
- If you changed any files locally, you must commit them using mcp__local_git_ops__commit_files AND push the branch using mcp__local_git_ops__push_branch before saying that you're done. - If you changed any files locally, you must commit them using mcp__local_git_ops__commit_files AND push the branch using mcp__local_git_ops__push_branch before saying that you're done.
${!eventData.isPR || !eventData.claudeBranch ? `- If you created a branch and made changes, your comment must include the PR URL with prefilled title and body mentioned above.` : ""} ${!eventData.isPR || !eventData.claudeBranch ? `- If you created a branch and made changes, you must create a PR using mcp__local_git_ops__create_pull_request.` : ""}
Important Notes: Important Notes:
- All communication must happen through Gitea PR comments. - All communication must happen through Gitea PR comments.
@@ -667,10 +645,6 @@ What You CAN Do:
- Create new branches when needed using the create_branch tool - Create new branches when needed using the create_branch tool
What You CANNOT Do: What You CANNOT Do:
- Submit formal Gitea PR reviews
- Approve pull requests (for security reasons)
- Post multiple comments (you only update your initial comment)
- Execute commands outside the repository context
- Run arbitrary Bash commands (unless explicitly allowed via allowed_tools configuration) - Run arbitrary Bash commands (unless explicitly allowed via allowed_tools configuration)
- Perform advanced branch operations (cannot merge branches, rebase, or perform other complex git operations beyond creating, checking out, and pushing branches) - Perform advanced branch operations (cannot merge branches, rebase, or perform other complex git operations beyond creating, checking out, and pushing branches)
- Modify files in the .github/workflows directory (Gitea App permissions do not allow workflow modifications) - Modify files in the .github/workflows directory (Gitea App permissions do not allow workflow modifications)

View File

@@ -52,7 +52,7 @@ export async function setupBranch(
); );
// Check out the base branch and let Claude create branches as needed // Check out the base branch and let Claude create branches as needed
await $`git fetch origin ${sourceBranch}`; await $`git fetch origin --depth=1 ${sourceBranch}`;
await $`git checkout ${sourceBranch}`; await $`git checkout ${sourceBranch}`;
await $`git pull origin ${sourceBranch}`; await $`git pull origin ${sourceBranch}`;
@@ -99,7 +99,7 @@ export async function setupBranch(
// Ensure we have the latest version of the source branch // Ensure we have the latest version of the source branch
console.log(`Fetching latest ${sourceBranch}...`); console.log(`Fetching latest ${sourceBranch}...`);
await $`git fetch origin ${sourceBranch}`; await $`git fetch origin --depth=1 ${sourceBranch}`;
// Checkout the source branch // Checkout the source branch
console.log(`Checking out ${sourceBranch}...`); console.log(`Checking out ${sourceBranch}...`);

View File

@@ -85,7 +85,7 @@ export async function branchHasChanges(
*/ */
export async function fetchBranch(branchName: string): Promise<boolean> { export async function fetchBranch(branchName: string): Promise<boolean> {
try { try {
await $`git fetch origin ${branchName}`; await $`git fetch origin --depth=1 ${branchName}`;
return true; return true;
} catch (error) { } catch (error) {
console.log( console.log(