From 6e96c33356b256af18b10e00923c63fb204fc289 Mon Sep 17 00:00:00 2001 From: Michelle Noorali Date: Thu, 24 Mar 2016 14:29:19 -0600 Subject: [PATCH] feat(repo): prevent from adding duplicate repos --- pkg/repo/inmem_repo_service.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/repo/inmem_repo_service.go b/pkg/repo/inmem_repo_service.go index 902320e74..86d05e9db 100644 --- a/pkg/repo/inmem_repo_service.go +++ b/pkg/repo/inmem_repo_service.go @@ -60,9 +60,14 @@ func (rs *inmemRepoService) CreateRepo(repository IRepo) error { defer rs.Unlock() URL := repository.GetURL() - _, ok := rs.repositories[URL] - if ok { - return fmt.Errorf("Repository with URL %s already exists", URL) + name := repository.GetName() + + for u, r := range rs.repositories { + if u == URL { + return fmt.Errorf("Repository with URL %s already exists", URL) + } else if r.GetName() == name { + return fmt.Errorf("Repository with Name %s already exists", name) + } } rs.repositories[URL] = repository