Rename project to git-project-manager
All checks were successful
Build and Publish / release (push) Successful in 1m10s
All checks were successful
Build and Publish / release (push) Successful in 1m10s
This commit is contained in:
13
internal/cache/cache.go
vendored
13
internal/cache/cache.go
vendored
@ -7,10 +7,11 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes"
|
||||
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/projects"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type Cache struct {
|
||||
@ -65,7 +66,7 @@ func (c *Cache) LockCache() {
|
||||
c.log.Info("Attempting to lock cache")
|
||||
c.checkLock()
|
||||
|
||||
file, err := os.OpenFile(c.file+".lock", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0640)
|
||||
file, err := os.OpenFile(c.file+".lock", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o640)
|
||||
defer file.Close()
|
||||
|
||||
if err != nil {
|
||||
@ -81,7 +82,7 @@ func (c *Cache) checkLock() {
|
||||
|
||||
// Saves the current state of the cache to disk
|
||||
func (c *Cache) write() {
|
||||
file, err := os.OpenFile(c.file, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0640)
|
||||
file, err := os.OpenFile(c.file, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o640)
|
||||
if err != nil {
|
||||
c.log.Error("Failed to write cache to disk", c.log.Args("error", err))
|
||||
}
|
||||
@ -92,6 +93,7 @@ func (c *Cache) write() {
|
||||
c.log.Debug("Cache saved to disk")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cache) Write() {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
@ -132,6 +134,7 @@ func (c *Cache) clear(clearAliases bool) {
|
||||
}
|
||||
c.setUpdated()
|
||||
}
|
||||
|
||||
func (c *Cache) Clear(clearAliases bool) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
@ -148,7 +151,7 @@ func (c *Cache) refresh(remotes ...string) {
|
||||
c.LoadRemotes(remotes...)
|
||||
}
|
||||
|
||||
// Iterates through all GitLab projects the user has access to, updating
|
||||
// Iterates through all Git projects the user has access to, updating
|
||||
// the project cache where necessary
|
||||
func (c *Cache) Refresh(remotes ...string) {
|
||||
c.lock.Lock()
|
||||
@ -210,5 +213,5 @@ func NewProjectCache(opts *CacheOpts) (*Cache, error) {
|
||||
}
|
||||
|
||||
func createProjectCache(path string) error {
|
||||
return os.WriteFile(path, nil, 0640)
|
||||
return os.WriteFile(path, nil, 0o640)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func (p *Project) GetGitInfo() string {
|
||||
commit, _ := repo.CommitObject(head.Hash())
|
||||
str += "\n" + commit.String()
|
||||
|
||||
str += pterm.LightMagenta("GitLab: ") + pterm.Bold.Sprint(p.HTTPURLToRepo) + "\n"
|
||||
str += pterm.LightMagenta("Git: ") + pterm.Bold.Sprint(p.HTTPURLToRepo) + "\n"
|
||||
|
||||
if remotes, _ := repo.Remotes(); len(remotes) > 0 {
|
||||
str += pterm.LightBlue("Remote: ") + pterm.Bold.Sprint(remotes[0].Config().URLs[0])
|
||||
|
Reference in New Issue
Block a user