(ctx context.Context, targetRepo string, opts UpdateWorkflowsOptions, createPR bool, verbose bool)
| 275 | } |
| 276 | |
| 277 | func runUpdateForTargetRepo(ctx context.Context, targetRepo string, opts UpdateWorkflowsOptions, createPR bool, verbose bool) error { |
| 278 | gitRoot, err := gitutil.FindGitRoot() |
| 279 | if err != nil { |
| 280 | return fmt.Errorf("--repo requires running inside a git repository: %w", err) |
| 281 | } |
| 282 | |
| 283 | updatesDir, err := ensureUpdateTargetRepoGitignore(gitRoot) |
| 284 | if err != nil { |
| 285 | return err |
| 286 | } |
| 287 | |
| 288 | checkoutDir := filepath.Join(updatesDir, sanitizeRepoPath(targetRepo)) |
| 289 | if err := shallowCloneTargetRepo(ctx, targetRepo, checkoutDir); err != nil { |
| 290 | return err |
| 291 | } |
| 292 | |
| 293 | if verbose { |
| 294 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Checked out "+targetRepo+" at "+checkoutDir)) |
| 295 | } |
| 296 | |
| 297 | originalDir, err := os.Getwd() |
| 298 | if err != nil { |
| 299 | return fmt.Errorf("failed to read current directory: %w", err) |
| 300 | } |
| 301 | defer func() { |
| 302 | _ = os.Chdir(originalDir) |
| 303 | }() |
| 304 | |
| 305 | if err := os.Chdir(checkoutDir); err != nil { |
| 306 | return fmt.Errorf("failed to change directory to checkout %s: %w", checkoutDir, err) |
| 307 | } |
| 308 | |
| 309 | if createPR { |
| 310 | if err := PreflightCheckForCreatePR(verbose); err != nil { |
| 311 | return err |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | if err := RunUpdateWorkflows(ctx, opts); err != nil { |
| 316 | return err |
| 317 | } |
| 318 | |
| 319 | if createPR { |
| 320 | releaseTag, releaseURL := getGhawReleaseInfo() |
| 321 | xmlMarker := buildOrgXMLMarker(ghawUpdateMarkerPrefix, releaseTag) |
| 322 | |
| 323 | // Close any stale update PRs in the target repo before creating the new one. |
| 324 | closeExistingOrgPRsByMarker(ctx, targetRepo, ghawUpdateMarkerPrefix, verbose) |
| 325 | |
| 326 | var releaseLine string |
| 327 | if releaseURL != "" { |
| 328 | releaseLine = fmt.Sprintf("\n[View gh-aw release %s](%s)\n", releaseTag, releaseURL) |
| 329 | } |
| 330 | prBody := "This PR updates agentic workflows from their source repositories." + |
| 331 | releaseLine + "\n" + xmlMarker |
| 332 | |
| 333 | prURL, err := CreatePRWithChanges("update-workflows", "chore: update workflows", |
| 334 | "Update workflows from source", prBody, verbose) |
no test coverage detected