cache

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProjectAliasesString

func ProjectAliasesString(aliases []*ProjectAlias) string

Types

type Cache

type Cache struct {
	Projects []*projects.Project
	Aliases  []*ProjectAlias
	Updated  time.Time

	CacheVersion string
	// contains filtered or unexported fields
}

func NewProjectCache

func NewProjectCache(opts *CacheOpts) (*Cache, error)

Returns a new project cache ready to load from cache file. Cache.Load() must be called manually

func (*Cache) AddAlias

func (c *Cache) AddAlias(alias string, project *projects.Project) error

func (*Cache) AddProjects

func (c *Cache) AddProjects(gitProjects ...*projects.Project)

func (*Cache) AliasStrings

func (c *Cache) AliasStrings(prefix string) []string

func (*Cache) AliasesByProjectString

func (c *Cache) AliasesByProjectString(remotes ...string) string

func (*Cache) Clear

func (c *Cache) Clear(clearAliases bool)

func (*Cache) DeleteAlias

func (c *Cache) DeleteAlias(alias *ProjectAlias)

func (*Cache) DoMigrations added in v0.2.0

func (c *Cache) DoMigrations() (error, int)

Performs any required updates based on version of cache read from disk. Does not check to ensure migrations were successful, only checks if a version has been achieved

func (*Cache) DumpString

func (c *Cache) DumpString(all bool, search string, remotes ...string) string

This command will only dump projects that have been cloned locally. Setting all to true will list all projects

func (*Cache) FuzzyFindAlias

func (c *Cache) FuzzyFindAlias(name string) []*ProjectAlias

Performs a fuzzy find on the input string, returning the closest matched based on its Levenshtein distance, along with an integer indicating number of matches found

func (*Cache) FuzzyFindProjects

func (c *Cache) FuzzyFindProjects(search string) []*projects.Project

Returns all matching projects by fuzzy find term Matches NameWithNamespace and Aliases

func (*Cache) GetAliasByName

func (c *Cache) GetAliasByName(name string, remotes ...string) *ProjectAlias

func (*Cache) GetProjectAliasStrings

func (c *Cache) GetProjectAliasStrings(project *projects.Project) []string

func (*Cache) GetProjectAliases

func (c *Cache) GetProjectAliases(project *projects.Project) []*ProjectAlias

func (*Cache) GetProjectByAlias

func (c *Cache) GetProjectByAlias(alias *ProjectAlias) *projects.Project

func (*Cache) GetProjectByID

func (c *Cache) GetProjectByID(id string) *projects.Project

func (*Cache) GetProjectByPath

func (c *Cache) GetProjectByPath(path string) *projects.Project

func (*Cache) GetProjectByRemoteAndId

func (c *Cache) GetProjectByRemoteAndId(remote string, id int) *projects.Project

func (*Cache) GetProjectFromCwd

func (c *Cache) GetProjectFromCwd() (*projects.Project, error)

func (*Cache) GetProjectPath

func (c *Cache) GetProjectPath(p *projects.Project) string

func (*Cache) GetProjectStringWithAliases

func (c *Cache) GetProjectStringWithAliases(project *projects.Project) string

func (*Cache) GetProjectsByID

func (c *Cache) GetProjectsByID(id int) []*projects.Project

Plural form of GetProjectByID Since multiple remotes may have the same project ID, this will return all matching

func (*Cache) GetProjectsWithAliases

func (c *Cache) GetProjectsWithAliases() []*projects.Project

func (*Cache) GetUpdated

func (c *Cache) GetUpdated() time.Time

func (*Cache) GoTo

func (c *Cache) GoTo(project *projects.Project)

func (*Cache) IsProjectCloned

func (c *Cache) IsProjectCloned(p *projects.Project) bool

func (*Cache) Load

func (c *Cache) Load() error

Load cache, if already loaded and up to date, nothing is done. If the cache is not yet loaded from disk, it is loaded If the updated timestamp is beyond the set ttl, a refresh is triggered

func (*Cache) LoadRemotes

func (c *Cache) LoadRemotes(gitRemotes ...string)

func (*Cache) LockCache

func (c *Cache) LockCache()

func (*Cache) OpenProject

func (c *Cache) OpenProject(ctx context.Context, project *projects.Project) *git.Repository

Will either read in the current repo, preparing a report on its current state, or will clone the project if it has not already been cloned in its path

func (*Cache) PrepProjectPath

func (c *Cache) PrepProjectPath(path string)

func (*Cache) ProjectString

func (c *Cache) ProjectString(p *projects.Project) string

func (*Cache) ProjectStrings

func (c *Cache) ProjectStrings(prefix string) []string

func (*Cache) Read

func (c *Cache) Read() error

Loads and unmarshals the project cache from disk.

func (*Cache) ReceiveRemoteStream

func (c *Cache) ReceiveRemoteStream(remote remote.Remote, wg *sync.WaitGroup, pBar *pterm.ProgressbarPrinter, progressInfo *load.ProgressInfo)

func (*Cache) Refresh

func (c *Cache) Refresh(remotes ...string)

Iterates through all Git projects the user has access to, updating the project cache where necessary

func (*Cache) SetUpdated

func (c *Cache) SetUpdated()

func (*Cache) String

func (c *Cache) String() string

func (*Cache) UnlockCache

func (c *Cache) UnlockCache()

func (*Cache) Write

func (c *Cache) Write()

type CacheOpts

type CacheOpts struct {
	Path         string
	ProjectsPath string
	TTL          time.Duration
	Logger       *pterm.Logger
	Remotes      *remotes.Remotes
	Config       *config.Config
}

type ProjectAlias

type ProjectAlias struct {
	Alias     string
	ProjectID int
	ID        string
	Remote    string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL