feat(repo): prevent from adding duplicate repos

pull/448/head
Michelle Noorali 9 years ago
parent e86b8db694
commit 6e96c33356

@ -60,9 +60,14 @@ func (rs *inmemRepoService) CreateRepo(repository IRepo) error {
defer rs.Unlock() defer rs.Unlock()
URL := repository.GetURL() URL := repository.GetURL()
_, ok := rs.repositories[URL] name := repository.GetName()
if ok {
for u, r := range rs.repositories {
if u == URL {
return fmt.Errorf("Repository with URL %s already exists", 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 rs.repositories[URL] = repository

Loading…
Cancel
Save