(repoID model.RepoID, line string)
| 340 | return err |
| 341 | } |
| 342 | if err := s.retryGitOperationForRemotes(ctx, GitOperationClone, cfg.Name, []string{cfg.RemoteURL}, attempt); err != nil { |
| 343 | return err |
| 344 | } |
| 345 | defer os.RemoveAll(target) |
| 346 | |
| 347 | targetGitDir := filepath.Join(target, ".git") |
| 348 | |
| 349 | if err := configureArtifactWorktree(ctx, targetGitDir); err != nil { |
| 350 | return err |
| 351 | } |
| 352 | // Populate the index so git status works inside the mount. |
| 353 | if _, err := runGit(ctx, targetGitDir, "read-tree", "HEAD"); err != nil { |
| 354 | return err |
| 355 | } |
| 356 | if err := os.Rename(filepath.Join(target, ".git"), cfg.GitDir); err != nil { |
| 357 | return err |
| 358 | } |
| 359 | s.invalidateBatchPool(cfg.GitDir) |
| 360 | return nil |
| 361 | } |
| 362 | |
| 363 | // PrepareSource acquires and verifies one exact remote source revision. |
| 364 | func (s *Store) PrepareSource(ctx context.Context, cfg model.RepoConfig, requirement model.SourceRequirement) (model.PreparedSource, error) { |
| 365 | requirement.Ref = strings.TrimSpace(requirement.Ref) |
| 366 | requirement.RequiredCommit = strings.ToLower(strings.TrimSpace(requirement.RequiredCommit)) |
| 367 | if requirement.Ref == "" || !strings.HasPrefix(requirement.Ref, "refs/") { |
| 368 | return model.PreparedSource{}, errors.New("source ref must be a canonical refs/... name") |
| 369 | } |
| 370 | if _, err := runGit(ctx, "", "check-ref-format", requirement.Ref); err != nil { |
| 371 | return model.PreparedSource{}, fmt.Errorf("invalid source ref %q", requirement.Ref) |
no test coverage detected