Skip to content

Commit 863fb4e

Browse files
committed
refactor(vcs): rename RepoPath to RepoInfo
1 parent 34abf69 commit 863fb4e

5 files changed

Lines changed: 16 additions & 16 deletions

File tree

internal/scan/scan.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
func FindRepos(
1919
roots []string,
2020
dirignore []string,
21-
) (repoPaths []vcs.RepoPath, warnings []string) {
21+
) (repos []vcs.RepoInfo, warnings []string) {
2222
matcher := NewIgnoreMatcher(roots, dirignore)
2323

2424
visitedDir := map[string]struct{}{}
@@ -47,7 +47,7 @@ func FindRepos(
4747
visitedDir[path] = struct{}{}
4848

4949
if repoType, ok := detectRepoType(path); ok {
50-
repoPaths = append(repoPaths, vcs.RepoPath{
50+
repos = append(repos, vcs.RepoInfo{
5151
Path: path,
5252
Type: repoType,
5353
})
@@ -57,7 +57,7 @@ func FindRepos(
5757
})
5858
}
5959

60-
return removeDuplicateRepoPaths(repoPaths), warnings
60+
return removeDuplicateRepoInfo(repos), warnings
6161
}
6262

6363
func detectRepoType(path string) (vcs.Type, bool) {
@@ -100,14 +100,14 @@ func isJJRepo(path string) bool {
100100
return info.IsDir()
101101
}
102102

103-
func removeDuplicateRepoPaths(repoPaths []vcs.RepoPath) []vcs.RepoPath {
104-
seen := make(map[string]struct{}, len(repoPaths))
105-
distinct := make([]vcs.RepoPath, 0, len(repoPaths))
103+
func removeDuplicateRepoInfo(repos []vcs.RepoInfo) []vcs.RepoInfo {
104+
seen := make(map[string]struct{}, len(repos))
105+
distinct := make([]vcs.RepoInfo, 0, len(repos))
106106

107-
for _, repoPath := range repoPaths {
108-
if _, ok := seen[repoPath.Path]; !ok {
109-
seen[repoPath.Path] = struct{}{}
110-
distinct = append(distinct, repoPath)
107+
for _, repo := range repos {
108+
if _, ok := seen[repo.Path]; !ok {
109+
seen[repo.Path] = struct{}{}
110+
distinct = append(distinct, repo)
111111
}
112112
}
113113

internal/scan/scan_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func writeFile(t *testing.T, path string, contents string) {
2323
}
2424
}
2525

26-
func repoTypeByPath(repos []vcs.RepoPath) map[string]vcs.Type {
26+
func repoTypeByPath(repos []vcs.RepoInfo) map[string]vcs.Type {
2727
result := map[string]vcs.Type{}
2828
for _, repo := range repos {
2929
result[repo.Path] = repo.Type

internal/vcs/concurrent.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type repoResult struct {
1515
}
1616

1717
func GetRepoStatesConcurrent(
18-
repos []RepoPath,
18+
repos []RepoInfo,
1919
registry *Registry,
2020
maxWorkers int,
2121
) ([]report.RepoState, []string) {
@@ -26,7 +26,7 @@ func GetRepoStatesConcurrent(
2626
states := []report.RepoState{}
2727
warnings := []string{}
2828

29-
jobs := make(chan RepoPath, maxWorkers*2)
29+
jobs := make(chan RepoInfo, maxWorkers*2)
3030
results := make(chan repoResult, maxWorkers*2)
3131

3232
var wg sync.WaitGroup

internal/vcs/concurrent_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (p stubProvider) CheckRepoState(path string) (report.RepoState, []string) {
2828
}
2929

3030
func TestGetRepoStatesConcurrent_SortsResultsAndPreservesWarnings(t *testing.T) {
31-
repos := []RepoPath{
31+
repos := []RepoInfo{
3232
{Path: "/tmp/z-jj", Type: TypeJJ},
3333
{Path: "/tmp/a-git", Type: TypeGit},
3434
{Path: "/tmp/m-jj", Type: TypeJJ},
@@ -78,7 +78,7 @@ func TestGetRepoStatesConcurrent_SortsResultsAndPreservesWarnings(t *testing.T)
7878
}
7979

8080
func TestGetRepoStatesConcurrent_WarnsWhenProviderIsMissing(t *testing.T) {
81-
repos := []RepoPath{{Path: "/tmp/repo", Type: TypeJJ}}
81+
repos := []RepoInfo{{Path: "/tmp/repo", Type: TypeJJ}}
8282

8383
states, warnings := GetRepoStatesConcurrent(repos, NewRegistry(), 1)
8484

internal/vcs/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const (
77
TypeJJ Type = "jj"
88
)
99

10-
type RepoPath struct {
10+
type RepoInfo struct {
1111
Path string
1212
Type Type
1313
}

0 commit comments

Comments
 (0)