Skip to content

Commit c294acc

Browse files
ashwin-antclaude
andcommitted
revert: undo PR checkout fork support and unique branch naming
Reverts the following commits: - f669191 fix: use unique local branch names for PR checkout to avoid conflicts (#931) - 21e3fe0 Fix PR checkout to support fork PRs (#851) Simplifies PR branch checkout back to using headRefName directly instead of the pr-{number} local branch naming scheme introduced in #931 and the GitHub pull ref fetch approach introduced in #851. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent f669191 commit c294acc

1 file changed

Lines changed: 6 additions & 21 deletions

File tree

src/github/operations/branch.ts

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,7 @@ export async function setupBranch(
151151
// Handle open PR: Checkout the PR branch
152152
console.log("This is an open PR, checking out PR branch...");
153153

154-
const originalBranchName = prData.headRefName;
155-
// Use unique local branch name to avoid conflicts with existing branches
156-
// Format: pr-{number} ensures uniqueness since PR numbers are unique per repo
157-
const localBranchName = `pr-${entityNumber}`;
154+
const branchName = prData.headRefName;
158155

159156
// Determine optimal fetch depth based on PR commit count, with a minimum of 20
160157
const commitCount = prData.commits.totalCount;
@@ -163,36 +160,24 @@ export async function setupBranch(
163160
console.log(
164161
`PR #${entityNumber}: ${commitCount} commits, using fetch depth ${fetchDepth}`,
165162
);
166-
console.log(
167-
`Fetching PR branch '${originalBranchName}' as local branch '${localBranchName}'`,
168-
);
169163

170164
// Validate branch names before use to prevent command injection
171-
validateBranchName(localBranchName);
165+
validateBranchName(branchName);
172166

173167
// Execute git commands to checkout PR branch (dynamic depth based on PR size)
174168
// Using execFileSync instead of shell template literals for security
175-
// Use GitHub's PR ref which works for both same-repo and fork PRs
176-
// The local branch name uses pr-{number} format to ensure uniqueness
177-
execGit([
178-
"fetch",
179-
"origin",
180-
`--depth=${fetchDepth}`,
181-
`pull/${entityNumber}/head:${localBranchName}`,
182-
]);
183-
execGit(["checkout", localBranchName, "--"]);
169+
execGit(["fetch", "origin", `--depth=${fetchDepth}`, branchName]);
170+
execGit(["checkout", branchName, "--"]);
184171

185-
console.log(
186-
`Successfully checked out PR #${entityNumber} as local branch '${localBranchName}'`,
187-
);
172+
console.log(`Successfully checked out PR branch for PR #${entityNumber}`);
188173

189174
// For open PRs, we need to get the base branch of the PR
190175
const baseBranch = prData.baseRefName;
191176
validateBranchName(baseBranch);
192177

193178
return {
194179
baseBranch,
195-
currentBranch: localBranchName,
180+
currentBranch: branchName,
196181
};
197182
}
198183
}

0 commit comments

Comments
 (0)