* Resolve the on-disk working directory in which a sample's patch should be * staged (branch created + patch committed). * * For cross-repo checkouts placed in a subdirectory (e.g. `path: github`), the * branch and commit must be created inside that subdirectory so the safe-outputs * MCP handle
(entry, workspace)
| 309 | * @returns {string} |
| 310 | */ |
| 311 | function resolvePatchWorkspace(entry, workspace) { |
| 312 | let targetRepo = ""; |
| 313 | if (entry.arguments && typeof entry.arguments.repo === "string" && entry.arguments.repo.trim()) { |
| 314 | targetRepo = entry.arguments.repo.trim(); |
| 315 | } else { |
| 316 | targetRepo = readConfiguredTargetRepo(entry.tool); |
| 317 | } |
| 318 | if (!targetRepo) { |
| 319 | return workspace; |
| 320 | } |
| 321 | try { |
| 322 | const result = findRepoCheckout(targetRepo, workspace); |
| 323 | if (result && result.success && result.path) { |
| 324 | if (path.resolve(result.path) !== path.resolve(workspace)) { |
| 325 | core.info(`apply_samples: staging patch for ${targetRepo} in checkout subdirectory ${result.path}`); |
| 326 | } |
| 327 | return result.path; |
| 328 | } |
| 329 | core.debug(`apply_samples: findRepoCheckout(${targetRepo}) did not locate a checkout; using workspace root`); |
| 330 | } catch (err) { |
| 331 | core.debug(`apply_samples: findRepoCheckout(${targetRepo}) failed: ${getErrorMessage(err)}; using workspace root`); |
| 332 | } |
| 333 | return workspace; |
| 334 | } |
| 335 | |
| 336 | /** |
| 337 | * Pre-stage a branch + patch for samples whose tool reads the workspace diff. |
no test coverage detected