-
Notifications
You must be signed in to change notification settings - Fork 361
Handle side-repo checkouts in push_to_pull_request_branch by scoping git ops to target repo cwd
#27894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle side-repo checkouts in push_to_pull_request_branch by scoping git ops to target repo cwd
#27894
Changes from all commits
427b6f0
f9c3d7b
0abeb95
b7a93af
67491cd
eba5f7a
b89a7a1
9ef1733
9dde06d
2c81766
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -486,10 +486,37 @@ function createHandlers(server, appendSafeOutput, config = {}) { | |||||||
| // Get base branch for the resolved target repository | ||||||||
| const baseBranch = await getBaseBranch(repoParts); | ||||||||
|
|
||||||||
| // Determine the working directory for git operations | ||||||||
| // If repo is specified, find where it's checked out | ||||||||
| let repoCwd = null; | ||||||||
| if (entry.repo && entry.repo.trim()) { | ||||||||
| const repoSlug = repoResult.repo; | ||||||||
| const checkoutResult = findRepoCheckout(repoSlug); | ||||||||
| if (!checkoutResult.success) { | ||||||||
| return { | ||||||||
| content: [ | ||||||||
| { | ||||||||
| type: "text", | ||||||||
| text: JSON.stringify({ | ||||||||
| result: "error", | ||||||||
| error: | ||||||||
| `Repository checkout not found for ${repoSlug}. Ensure the repository is checked out in this workflow using actions/checkout. ` + | ||||||||
| "If checking out multiple repositories, use the 'path' input so the checkout can be located.", | ||||||||
| }), | ||||||||
| }, | ||||||||
| ], | ||||||||
| isError: true, | ||||||||
| }; | ||||||||
| } | ||||||||
| repoCwd = checkoutResult.path; | ||||||||
| entry.repo_cwd = repoCwd; | ||||||||
| server.debug(`Selected checkout folder for ${repoSlug}: ${repoCwd}`); | ||||||||
| } | ||||||||
|
|
||||||||
| // If branch is not provided, is empty, or equals the base branch, use the current branch from git | ||||||||
| // This handles cases where the agent incorrectly passes the base branch instead of the working branch | ||||||||
| if (!entry.branch || entry.branch.trim() === "" || entry.branch === baseBranch) { | ||||||||
| const detectedBranch = getCurrentBranch(); | ||||||||
| const detectedBranch = getCurrentBranch(repoCwd); | ||||||||
|
|
||||||||
| if (entry.branch === baseBranch) { | ||||||||
| server.debug(`Branch equals base branch (${baseBranch}), detecting actual working branch: ${detectedBranch}`); | ||||||||
|
|
@@ -507,6 +534,10 @@ function createHandlers(server, appendSafeOutput, config = {}) { | |||||||
|
|
||||||||
| // Build common options for both patch and bundle generation | ||||||||
| const pushTransportOptions = { mode: "incremental" }; | ||||||||
| if (repoCwd) { | ||||||||
| pushTransportOptions.cwd = repoCwd; | ||||||||
|
||||||||
| pushTransportOptions.cwd = repoCwd; | |
| pushTransportOptions.cwd = repoCwd; | |
| pushTransportOptions.repoSlug = repoResult.repo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot log the select folder location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the checkout-folder debug log in
2c81766and covered it with a targeted test assertion. Screenshot: N/A (no UI changes).