mirror of
https://github.com/grdl/git-get.git
synced 2026-02-09 22:44:16 +00:00
Load repos status simultaneously with goroutines
Also, refactor printer interface.
This commit is contained in:
@@ -4,13 +4,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DumpRepo is a git repository printable into a dump file.
|
||||
type DumpRepo interface {
|
||||
Path() string
|
||||
Remote() (string, error)
|
||||
CurrentBranch() (string, error)
|
||||
}
|
||||
|
||||
// DumpPrinter prints a list of repos in a dump file format.
|
||||
type DumpPrinter struct{}
|
||||
|
||||
@@ -21,20 +14,14 @@ func NewDumpPrinter() *DumpPrinter {
|
||||
|
||||
// Print generates a list of repos URLs. Each line contains a URL and, if applicable, a currently checked out branch name.
|
||||
// It's a way to dump all repositories managed by git-get and is supposed to be consumed by `git get --dump`.
|
||||
func (p *DumpPrinter) Print(repos []DumpRepo) string {
|
||||
func (p *DumpPrinter) Print(repos []Printable) string {
|
||||
var str strings.Builder
|
||||
|
||||
for i, r := range repos {
|
||||
url, err := r.Remote()
|
||||
if err != nil {
|
||||
continue
|
||||
// TODO: handle error?
|
||||
}
|
||||
str.WriteString(r.Remote())
|
||||
|
||||
str.WriteString(url)
|
||||
|
||||
current, err := r.CurrentBranch()
|
||||
if err != nil || current != detached {
|
||||
// TODO: if head is detached maybe we should get the revision it points to in case it's a tag
|
||||
if current := r.Current(); current != "" && current != head {
|
||||
str.WriteString(" " + current)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user