ignore new repos until init()
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
8c415947df
commit
98926bf2f8
22
common.go
22
common.go
|
@ -5,8 +5,10 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gui/shell"
|
||||
"go.wit.com/lib/gui/repostatus"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
@ -23,6 +25,11 @@ func (r *RepoList) Hide() {
|
|||
r.reposbox.Hide()
|
||||
}
|
||||
|
||||
// better name: use this
|
||||
func (r *RepoList) FindRepoByName(path string) *RepoRow {
|
||||
return r.FindRepo(path)
|
||||
}
|
||||
|
||||
func (r *RepoList) FindRepo(path string) *RepoRow {
|
||||
repo, _ := me.allrepos[path]
|
||||
return repo
|
||||
|
@ -219,3 +226,18 @@ func (rl *RepoList) MakeGoWork() error {
|
|||
fmt.Fprintln(f, ")")
|
||||
return nil
|
||||
}
|
||||
|
||||
// makes a human readable thing for standard out.
|
||||
func (r *RepoRow) StandardHeader() string {
|
||||
lastTag := r.LastTag()
|
||||
tag := r.Status.NewestTag()
|
||||
gitAge, _ := tag.GetDate()
|
||||
dur := time.Since(gitAge)
|
||||
|
||||
master := r.Status.GetMasterVersion()
|
||||
devel := r.Status.GetDevelVersion()
|
||||
user := r.Status.GetUserVersion()
|
||||
|
||||
header := fmt.Sprintf("%-35s %5s %-10s %-10s %-10s %-10s %-15s", r.Name(), shell.FormatDuration(dur), lastTag, master, devel, user, r.State())
|
||||
return header
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ func (r *RepoList) NewRepo(path string) (*RepoRow, error) {
|
|||
}
|
||||
newRepo := new(RepoRow)
|
||||
newRepo.Status = status
|
||||
newRepo.Status.InitOk = false
|
||||
|
||||
newRepo.pLabel = r.reposgrid.NewLabel(path).SetProgName("path")
|
||||
newRepo.hidden = false
|
||||
|
@ -78,6 +79,7 @@ func (r *RepoList) NewRepo(path string) (*RepoRow, error) {
|
|||
r.makeAutotypistView(newRepo)
|
||||
}
|
||||
r.reposgrid.NextRow()
|
||||
newRepo.Status.InitOk = true
|
||||
return newRepo, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package repolist
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type RepoIterator struct {
|
||||
repos []*RepoRow
|
||||
index int
|
||||
}
|
||||
|
||||
// NewRepoIterator initializes a new iterator.
|
||||
func NewRepoIterator(repos []*RepoRow) *RepoIterator {
|
||||
return &RepoIterator{repos: repos}
|
||||
}
|
||||
|
||||
// Scan moves to the next element and returns false if there are no more repos.
|
||||
func (it *RepoIterator) Scan() bool {
|
||||
if it.index >= len(it.repos) {
|
||||
return false
|
||||
}
|
||||
it.index++
|
||||
return true
|
||||
}
|
||||
|
||||
// Repo returns the current repo.
|
||||
func (it *RepoIterator) Repo() *RepoRow {
|
||||
if it.repos[it.index-1] == nil {
|
||||
for i, d := range it.repos {
|
||||
fmt.Println("i =", i, d)
|
||||
}
|
||||
fmt.Println("len =", len(it.repos))
|
||||
fmt.Println("repo == nil", it.index, it.index-1)
|
||||
os.Exit(-1)
|
||||
}
|
||||
return it.repos[it.index-1]
|
||||
}
|
||||
|
||||
// Use Scan() in a loop, similar to a while loop
|
||||
//
|
||||
// for iterator.Scan() {
|
||||
// d := iterator.Repo()
|
||||
// fmt.Println("Repo UUID:", d.Uuid)
|
||||
// }
|
||||
|
||||
func (r *RepoList) ReposAll() *RepoIterator {
|
||||
repoPointers := r.selectRepoAll()
|
||||
|
||||
iterator := NewRepoIterator(repoPointers)
|
||||
|
||||
return iterator
|
||||
}
|
||||
|
||||
// SelectRepoPointers safely returns a slice of pointers to Repo records.
|
||||
func (r *RepoList) selectRepoAll() []*RepoRow {
|
||||
r.RLock()
|
||||
defer r.RUnlock()
|
||||
|
||||
// Create a new slice to hold pointers to each Repo
|
||||
// repoPointers := make([]*Repo, len(c.E.Repos))
|
||||
var repoPointers []*RepoRow
|
||||
for _, repo := range me.allrepos {
|
||||
if repo == nil {
|
||||
continue
|
||||
}
|
||||
if repo.Status == nil {
|
||||
continue
|
||||
}
|
||||
if ! repo.Status.InitOk {
|
||||
continue
|
||||
}
|
||||
repoPointers = append(repoPointers, repo) // Copy pointers for safe iteration
|
||||
}
|
||||
|
||||
return repoPointers
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package repolist
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gui/repostatus"
|
||||
)
|
||||
|
@ -17,6 +19,8 @@ func (b *RepoList) Enable() {
|
|||
|
||||
// this app's variables
|
||||
type RepoList struct {
|
||||
sync.RWMutex
|
||||
|
||||
onlyMe bool
|
||||
goSrcPwd string
|
||||
allrepos map[string]*RepoRow
|
||||
|
|
Loading…
Reference in New Issue