repolist/common.go

125 lines
2.3 KiB
Go
Raw Normal View History

2024-02-17 08:39:55 -06:00
package repolist
import (
"go.wit.com/lib/gui/repostatus"
)
func (r *RepoList) Hidden() bool {
2024-02-17 14:22:24 -06:00
return r.reposbox.Hidden()
2024-02-17 08:39:55 -06:00
}
func (r *RepoList) Show() {
2024-02-17 14:22:24 -06:00
r.reposbox.Show()
2024-02-17 08:39:55 -06:00
}
func (r *RepoList) Hide() {
2024-02-17 14:22:24 -06:00
r.reposbox.Hide()
2024-02-17 08:39:55 -06:00
}
2024-02-18 15:09:35 -06:00
func (r *RepoList) FindRepo(path string) *Repo {
repo, _ := me.allrepos[path]
return repo
}
2024-02-17 08:39:55 -06:00
func (r *RepoList) AllRepos() []*Repo {
var all []*Repo
for _, repo := range me.allrepos {
all = append(all, repo)
}
return all
}
// deprecate this
func AllRepos() []*Repo {
var all []*Repo
for _, repo := range me.allrepos {
all = append(all, repo)
}
return all
}
2024-02-17 15:48:56 -06:00
// a human readable state of the current repo
func (r *Repo) State() string {
2024-02-17 14:22:24 -06:00
return r.dirtyLabel.String()
}
2024-02-17 08:39:55 -06:00
func (r *Repo) Scan() bool {
2024-02-17 14:22:24 -06:00
return r.NewScan()
2024-02-17 08:39:55 -06:00
}
2024-02-17 15:48:56 -06:00
// returns a name for human consuption only
// todo: implement nicknames
func (rs *Repo) Name() string {
if rs.Status.IsGoLang() {
return rs.Status.GoPath()
}
return rs.Status.Path()
2024-02-17 08:39:55 -06:00
}
2024-02-17 15:48:56 -06:00
func (r *Repo) Exists(s string) bool {
return false
2024-02-17 08:39:55 -06:00
}
2024-02-17 15:48:56 -06:00
func (r *Repo) GoPath() string {
return r.Status.GoPath()
2024-02-17 08:39:55 -06:00
}
func (r *Repo) CheckDirty() bool {
2024-02-17 15:48:56 -06:00
return r.Status.CheckDirty()
2024-02-17 08:39:55 -06:00
}
func (r *Repo) IsDirty() bool {
2024-02-17 15:48:56 -06:00
return r.Status.IsDirty()
2024-02-17 08:39:55 -06:00
}
func (r *Repo) ReadOnly() bool {
2024-02-17 15:48:56 -06:00
return r.Status.ReadOnly()
2024-02-17 08:39:55 -06:00
}
2024-02-18 15:09:35 -06:00
func (r *Repo) LastTag() string {
return r.Status.GetLastTagVersion()
}
// returns the state of the GO go.mod and go.sum files
// this is used to tell if they are valid and correctly reflect
// the versions of the other GUI packages
// at this point in time, there is _NO_ way to be check our
// be sure that anything will run with older versions
// because this are changing too often at this point
// TODO: revisit this in 2025 or 2026
func (r *Repo) GoState() string {
return r.Status.GetGoSumStatus()
}
func (r *Repo) SetGoState(s string) {
r.Status.SetGoSumStatus(s)
}
2024-02-17 08:39:55 -06:00
func (r *Repo) IsPerfect() bool {
if r.dirtyLabel.String() == "PERFECT" {
return true
}
2024-02-17 14:22:24 -06:00
if r.dirtyLabel.String() == "unchanged" {
return true
}
2024-02-17 08:39:55 -06:00
return false
}
func (r *Repo) RunCmd(cmd []string) (error, string) {
2024-02-17 15:48:56 -06:00
return r.Status.RunCmd(cmd)
2024-02-17 08:39:55 -06:00
}
func (r *Repo) AllTags() []*repostatus.Tag {
2024-02-17 15:48:56 -06:00
return r.Status.Tags.ListAll()
2024-02-17 08:39:55 -06:00
}
func (r *Repo) TagsBox() *repostatus.GitTagBox {
2024-02-17 15:48:56 -06:00
return r.Status.Tags
2024-02-17 08:39:55 -06:00
}
// todo, fix bool return for deletetag()
func (r *Repo) DeleteTag(t *repostatus.Tag) bool {
2024-02-17 15:48:56 -06:00
r.Status.DeleteTag(t)
2024-02-17 08:39:55 -06:00
return true
}