mirror of
https://github.com/grdl/git-get.git
synced 2026-02-04 20:19:42 +00:00
Refactor package print into out to fix failing predeclared linter
This commit is contained in:
32
pkg/out/dump.go
Normal file
32
pkg/out/dump.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package out
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DumpPrinter prints a list of repos in a dump file format.
|
||||
type DumpPrinter struct{}
|
||||
|
||||
// NewDumpPrinter creates a DumpPrinter.
|
||||
func NewDumpPrinter() *DumpPrinter {
|
||||
return &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 []Printable) string {
|
||||
var str strings.Builder
|
||||
|
||||
for _, r := range repos {
|
||||
str.WriteString(r.Remote())
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
str.WriteString("\n")
|
||||
}
|
||||
|
||||
return str.String()
|
||||
}
|
||||
Reference in New Issue
Block a user