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:
claude[bot]
2025-05-31 05:27:07 +00:00
committed by GitHub
parent a8a36ced96
commit e8d2b8d5df
4 changed files with 124 additions and 51 deletions

View File

@@ -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 = "";