mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-24 07:24:12 +08:00
feat: persist issue branches for reuse on subsequent invocations
- Check for existing Claude branches before creating new ones for issues - Skip automatic branch deletion for issue branches to allow reuse - Add context awareness so Claude knows when reusing an existing branch - Set IS_REUSED_BRANCH output for tracking branch reuse status This change allows users to iteratively ask Claude to make changes on the same branch before creating a PR, as requested in issue #103. Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com>
This commit is contained in:
@@ -87,13 +87,29 @@ async function run() {
|
||||
const currentBody = comment.body ?? "";
|
||||
|
||||
// Check if we need to add branch link for new branches
|
||||
const { shouldDeleteBranch, branchLink } = await checkAndDeleteEmptyBranch(
|
||||
octokit,
|
||||
owner,
|
||||
repo,
|
||||
claudeBranch,
|
||||
baseBranch,
|
||||
);
|
||||
// For issues, we don't delete branches anymore to allow reuse
|
||||
const skipBranchDeletion = !context.isPR && claudeBranch;
|
||||
|
||||
let shouldDeleteBranch = false;
|
||||
let branchLink = "";
|
||||
|
||||
if (skipBranchDeletion) {
|
||||
// For issue branches, just add the branch link without checking for deletion
|
||||
const branchUrl = `${GITHUB_SERVER_URL}/${owner}/${repo}/tree/${claudeBranch}`;
|
||||
branchLink = `\n[View branch](${branchUrl})`;
|
||||
console.log(`Keeping issue branch ${claudeBranch} for potential reuse`);
|
||||
} else {
|
||||
// For PR branches, use the existing cleanup logic
|
||||
const result = await checkAndDeleteEmptyBranch(
|
||||
octokit,
|
||||
owner,
|
||||
repo,
|
||||
claudeBranch,
|
||||
baseBranch,
|
||||
);
|
||||
shouldDeleteBranch = result.shouldDeleteBranch;
|
||||
branchLink = result.branchLink;
|
||||
}
|
||||
|
||||
// Check if we need to add PR URL when we have a new branch
|
||||
let prLink = "";
|
||||
|
||||
Reference in New Issue
Block a user