diff options
Diffstat (limited to 'repos.go')
| -rw-r--r-- | repos.go | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -118,6 +118,23 @@ 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 (all *Repos) DeleteByName(name string) *Repo { + reposLock.Lock() + defer reposLock.Unlock() + + var newr Repo + + for i, _ := range all.Repos { + if all.Repos[i].Name == name { + newr = *all.Repos[i] + all.Repos[i] = all.Repos[len(all.Repos)-1] + all.Repos = all.Repos[:len(all.Repos)-1] + return &newr + } + } + return nil +} + // safely returns a slice of pointers to the Repo protobufs func (r *Repos) selectAllRepos() []*Repo { reposLock.RLock() |
