blob: 95b9b8a2225d4f1c40fd00c0d2b83f6d6ac32543 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package stats
import (
"regexp"
"strings"
"gitlab.com/gitlab-org/gitaly/v16/internal/git/repository"
"gitlab.com/gitlab-org/gitaly/v16/internal/praefect/praefectutil"
)
// railsPoolDirRegexp is used to validate object pool directory structure and name as generated by Rails.
var railsPoolDirRegexp = regexp.MustCompile(`^@pools/([0-9a-f]{2})/([0-9a-f]{2})/([0-9a-f]{64})\.git$`)
// IsRailsPoolRepository returns whether the repository is a pool repository generated by Rails.
func IsRailsPoolRepository(repo repository.GitRepo) bool {
matches := railsPoolDirRegexp.FindStringSubmatch(repo.GetRelativePath())
if matches == nil || !strings.HasPrefix(matches[3], matches[1]+matches[2]) {
return false
}
return true
}
// IsPoolRepository returns whether the repository is an object pool.
func IsPoolRepository(repo repository.GitRepo) bool {
return IsRailsPoolRepository(repo) || praefectutil.IsPoolRepository(repo)
}
|