gitindex: hide the FileKey type
Change-Id: I678e92ac3fe7c5c2b4124990edfe76a6d70439c9
diff --git a/cmd/zoekt-repo-index/main.go b/cmd/zoekt-repo-index/main.go
index 3f24b1d..3f2d097 100644
--- a/cmd/zoekt-repo-index/main.go
+++ b/cmd/zoekt-repo-index/main.go
@@ -52,6 +52,16 @@
var _ = log.Println
+type fileKey struct {
+ SubRepoPath string
+ Path string
+ ID plumbing.Hash
+}
+
+func (k *fileKey) FullPath() string {
+ return filepath.Join(k.SubRepoPath, k.Path)
+}
+
type branchFile struct {
branch, file string
mf *manifest.Manifest
@@ -168,7 +178,7 @@
}
}
- perBranch := map[string]map[gitindex.FileKey]gitindex.BlobLocation{}
+ perBranch := map[string]map[fileKey]gitindex.BlobLocation{}
opts.SubRepositories = map[string]*zoekt.Repository{}
// branch => repo => version
@@ -234,7 +244,7 @@
}
// key => branch
- all := map[gitindex.FileKey][]string{}
+ all := map[fileKey][]string{}
for br, files := range perBranch {
for k := range files {
all[k] = append(all[k], br)
@@ -316,8 +326,8 @@
// iterateManifest constructs a complete tree from the given Manifest.
func iterateManifest(mf *manifest.Manifest,
baseURL url.URL, revPrefix string,
- cache *gitindex.RepoCache) (map[gitindex.FileKey]gitindex.BlobLocation, map[string]plumbing.Hash, error) {
- allFiles := map[gitindex.FileKey]gitindex.BlobLocation{}
+ cache *gitindex.RepoCache) (map[fileKey]gitindex.BlobLocation, map[string]plumbing.Hash, error) {
+ allFiles := map[fileKey]gitindex.BlobLocation{}
allVersions := map[string]plumbing.Hash{}
for _, p := range mf.Project {
rev := mf.ProjectRevision(&p)
@@ -356,7 +366,7 @@
}
for key, repo := range files {
- allFiles[gitindex.FileKey{
+ allFiles[fileKey{
SubRepoPath: filepath.Join(p.GetPath(), key.SubRepoPath),
Path: key.Path,
ID: key.ID,
diff --git a/gitindex/git.go b/gitindex/git.go
index 99d118a..5ffa631 100644
--- a/gitindex/git.go
+++ b/gitindex/git.go
@@ -344,10 +344,10 @@
defer repoCache.Close()
// branch => (path, sha1) => repo.
- repos := map[FileKey]BlobLocation{}
+ repos := map[fileKey]BlobLocation{}
- // FileKey => branches
- branchMap := map[FileKey][]string{}
+ // fileKey => branches
+ branchMap := map[fileKey][]string{}
// Branch => Repo => SHA1
branchVersions := map[string]map[string]plumbing.Hash{}
@@ -426,7 +426,7 @@
}
var names []string
- fileKeys := map[string][]FileKey{}
+ fileKeys := map[string][]fileKey{}
for key := range repos {
n := key.FullPath()
fileKeys[n] = append(fileKeys[n], key)
diff --git a/gitindex/tree.go b/gitindex/tree.go
index 298c600..0491f2d 100644
--- a/gitindex/tree.go
+++ b/gitindex/tree.go
@@ -35,7 +35,7 @@
repo *git.Repository
repoURL *url.URL
- tree map[FileKey]BlobLocation
+ tree map[fileKey]BlobLocation
// Path => SubmoduleEntry
submodules map[string]*SubmoduleEntry
@@ -69,7 +69,7 @@
return &repoWalker{
repo: r,
repoURL: u,
- tree: map[FileKey]BlobLocation{},
+ tree: map[fileKey]BlobLocation{},
repoCache: repoCache,
subRepoVersions: map[string]plumbing.Hash{},
ignoreMissingSubmodules: true,
@@ -100,7 +100,7 @@
// non-nil, recurse into submodules. In addition, it returns a mapping
// that indicates in which repo each SHA1 can be found.
func TreeToFiles(r *git.Repository, t *object.Tree,
- repoURL string, repoCache *RepoCache) (map[FileKey]BlobLocation, map[string]plumbing.Hash, error) {
+ repoURL string, repoCache *RepoCache) (map[fileKey]BlobLocation, map[string]plumbing.Hash, error) {
rw := newRepoWalker(r, repoURL, repoCache)
if err := rw.parseModuleMap(t); err != nil {
@@ -163,7 +163,7 @@
return err
}
for k, repo := range subTree {
- r.tree[FileKey{
+ r.tree[fileKey{
SubRepoPath: filepath.Join(p, k.SubRepoPath),
Path: k.Path,
ID: k.ID,
@@ -188,7 +188,7 @@
return nil
}
- r.tree[FileKey{
+ r.tree[fileKey{
Path: p,
ID: e.Hash,
}] = BlobLocation{
@@ -198,15 +198,15 @@
return nil
}
-// FileKey describes a blob at a location in the final tree. We also
+// fileKey describes a blob at a location in the final tree. We also
// record the subrepository from where it came.
-type FileKey struct {
+type fileKey struct {
SubRepoPath string
Path string
ID plumbing.Hash
}
-func (k *FileKey) FullPath() string {
+func (k *fileKey) FullPath() string {
return filepath.Join(k.SubRepoPath, k.Path)
}