Move from --gitlab flags to global --remote flags
This commit is contained in:
16
internal/cache/cache.go
vendored
16
internal/cache/cache.go
vendored
@@ -17,7 +17,7 @@ type Cache struct {
|
||||
Projects []*projects.Project
|
||||
Aliases []*ProjectAlias
|
||||
Updated time.Time
|
||||
Remotes *remotes.Remotes
|
||||
remotes *remotes.Remotes
|
||||
config *config.Config
|
||||
readFromFile bool
|
||||
lock *sync.Mutex // Lock the entire cache
|
||||
@@ -138,22 +138,22 @@ func (c *Cache) Clear(clearAliases bool) {
|
||||
c.clear(clearAliases)
|
||||
}
|
||||
|
||||
func (c *Cache) refresh() {
|
||||
func (c *Cache) refresh(remotes ...string) {
|
||||
c.log.Info("Loading project cache, this may take a while\n")
|
||||
defer c.setUpdated()
|
||||
// Fix any dangling aliases
|
||||
// For backwards-compatibility only
|
||||
c.setAliasRemotes()
|
||||
// Retrieve and add/update projects
|
||||
c.LoadRemotes()
|
||||
c.LoadRemotes(remotes...)
|
||||
}
|
||||
|
||||
// Iterates through all GitLab projects the user has access to, updating
|
||||
// the project cache where necessary
|
||||
func (c *Cache) Refresh() {
|
||||
func (c *Cache) Refresh(remotes ...string) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
c.refresh()
|
||||
c.refresh(remotes...)
|
||||
}
|
||||
|
||||
func (c *Cache) String() string {
|
||||
@@ -161,9 +161,9 @@ func (c *Cache) String() string {
|
||||
c.Updated.String(),
|
||||
len(c.Projects),
|
||||
len(c.Aliases),
|
||||
len(*c.Remotes),
|
||||
len(*c.remotes),
|
||||
)
|
||||
for _, r := range *c.Remotes {
|
||||
for _, r := range *c.remotes {
|
||||
cacheString += " " + r.GetInfo().Host
|
||||
}
|
||||
return cacheString
|
||||
@@ -202,7 +202,7 @@ func NewProjectCache(opts *CacheOpts) (*Cache, error) {
|
||||
lock: &sync.Mutex{},
|
||||
contentLock: &sync.Mutex{},
|
||||
log: opts.Logger,
|
||||
Remotes: opts.Remotes,
|
||||
remotes: opts.Remotes,
|
||||
path: opts.ProjectsPath,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user