Skip to content

Commit 9b2bdf4

Browse files
committed
Added RepositoryList.Find(..) function
1 parent b7129d9 commit 9b2bdf4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

repos.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ type RepositoryList []*Repository
3535
// Contains check if a repository definition is already contained
3636
// in the RepositoryList
3737
func (r RepositoryList) Contains(repo *Repository) bool {
38-
for _, i := range r {
39-
if repo.Equals(i) {
40-
return true
38+
return r.Find(repo) != nil
39+
}
40+
41+
// Find search a repo in the RepositoryList that has metadata
42+
// matching with the one passed as parameter
43+
func (r RepositoryList) Find(repoToFind *Repository) *Repository {
44+
for _, repo := range r {
45+
if repoToFind.Equals(repo) {
46+
return repo
4147
}
4248
}
43-
return false
49+
return nil
4450
}
4551

4652
// Repository is a repository installed in the system

0 commit comments

Comments
 (0)