diff options
Diffstat (limited to 'repos.go')
| -rw-r--r-- | repos.go | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -61,22 +61,22 @@ func (r *Repos) All() *RepoIterator { return iterator } -func (r *Repos) SortByName() *RepoIterator { +func (r *Repos) SortByPath() *RepoIterator { packs := r.selectAllRepos() - sort.Sort(ByRepoName(packs)) + sort.Sort(ByRepoPath(packs)) iterator := NewRepoIterator(packs) return iterator } -// enforces no duplicate repo names +// enforces no duplicate repo paths func (r *Repos) Append(newP *Repo) bool { reposLock.Lock() defer reposLock.Unlock() for _, p := range r.Repos { - if p.Name == newP.Name { + if p.GoPath == newP.GoPath { return false } } @@ -91,13 +91,13 @@ func (r *Repo) Age(newP *Repo) time.Duration { return t } -// find a repo by name -func (r *Repos) FindByName(name string) *Repo { +// find a repo by path +func (r *Repos) FindByPath(gopath string) *Repo { reposLock.RLock() defer reposLock.RUnlock() for _, p := range r.Repos { - if p.Name == name { + if p.GoPath == gopath { return p } } @@ -112,20 +112,20 @@ func (r *Repos) Len() int { return len(r.Repos) } -type ByRepoName []*Repo +type ByRepoPath []*Repo -func (a ByRepoName) Len() int { return len(a) } -func (a ByRepoName) Less(i, j int) bool { return a[i].Name < a[j].Name } -func (a ByRepoName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByRepoPath) Len() int { return len(a) } +func (a ByRepoPath) Less(i, j int) bool { return a[i].GoPath < a[j].GoPath } +func (a ByRepoPath) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (all *Repos) DeleteByName(name string) *Repo { +func (all *Repos) DeleteByPath(gopath string) *Repo { reposLock.Lock() defer reposLock.Unlock() var newr Repo for i, _ := range all.Repos { - if all.Repos[i].Name == name { + if all.Repos[i].GoPath == gopath { newr = *all.Repos[i] all.Repos[i] = all.Repos[len(all.Repos)-1] all.Repos = all.Repos[:len(all.Repos)-1] |
