(path string)
| 590 | } |
| 591 | |
| 592 | func (s *GitTokenStore) relativeToRepo(path string) (string, error) { |
| 593 | repoDir := s.repoDirSnapshot() |
| 594 | if repoDir == "" { |
| 595 | return "", fmt.Errorf("git token store: repository path not configured") |
| 596 | } |
| 597 | absRepo := repoDir |
| 598 | if abs, err := filepath.Abs(repoDir); err == nil { |
| 599 | absRepo = abs |
| 600 | } |
| 601 | cleanPath := path |
| 602 | if abs, err := filepath.Abs(path); err == nil { |
| 603 | cleanPath = abs |
| 604 | } |
| 605 | rel, err := filepath.Rel(absRepo, cleanPath) |
| 606 | if err != nil { |
| 607 | return "", fmt.Errorf("git token store: relative path: %w", err) |
| 608 | } |
| 609 | if rel == ".." || strings.HasPrefix(rel, ".."+string(os.PathSeparator)) { |
| 610 | return "", fmt.Errorf("git token store: path outside repository") |
| 611 | } |
| 612 | return rel, nil |
| 613 | } |
| 614 | |
| 615 | func (s *GitTokenStore) checkoutConfiguredBranch(repo *git.Repository, worktree *git.Worktree, authMethod transport.AuthMethod) error { |
| 616 | branchRefName := plumbing.NewBranchReferenceName(s.branch) |
no test coverage detected