|
|
@ -97,13 +97,39 @@ func (r *repoListWriter) encodeByFormat(out io.Writer, format output.Format) err
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Returns all repos from repos, except those with names matching ignoredRepoNames
|
|
|
|
|
|
|
|
// Inspired by https://stackoverflow.com/a/28701031/893211
|
|
|
|
|
|
|
|
func filterRepos(repos []*repo.Entry, ignoredRepoNames []string) []*repo.Entry {
|
|
|
|
|
|
|
|
// if ignoredRepoNames is nil, just return repo
|
|
|
|
|
|
|
|
if ignoredRepoNames == nil {
|
|
|
|
|
|
|
|
return repos
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filteredRepos := make([]*repo.Entry, 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ignored := make(map[string]bool, 0)
|
|
|
|
|
|
|
|
for _, repo := range ignoredRepoNames {
|
|
|
|
|
|
|
|
ignored[repo] = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, repo := range repos {
|
|
|
|
|
|
|
|
_, removed := ignored[repo.Name]
|
|
|
|
|
|
|
|
if !removed {
|
|
|
|
|
|
|
|
filteredRepos = append(filteredRepos, repo)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return filteredRepos
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Provide dynamic auto-completion for repo names
|
|
|
|
// Provide dynamic auto-completion for repo names
|
|
|
|
func compListRepos(prefix string) []string {
|
|
|
|
func compListRepos(prefix string, ignoredRepoNames []string) []string {
|
|
|
|
var rNames []string
|
|
|
|
var rNames []string
|
|
|
|
|
|
|
|
|
|
|
|
f, err := repo.LoadFile(settings.RepositoryConfig)
|
|
|
|
f, err := repo.LoadFile(settings.RepositoryConfig)
|
|
|
|
if err == nil && len(f.Repositories) > 0 {
|
|
|
|
if err == nil && len(f.Repositories) > 0 {
|
|
|
|
for _, repo := range f.Repositories {
|
|
|
|
filteredRepos := filterRepos(f.Repositories, ignoredRepoNames)
|
|
|
|
|
|
|
|
for _, repo := range filteredRepos {
|
|
|
|
if strings.HasPrefix(repo.Name, prefix) {
|
|
|
|
if strings.HasPrefix(repo.Name, prefix) {
|
|
|
|
rNames = append(rNames, repo.Name)
|
|
|
|
rNames = append(rNames, repo.Name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|