6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-05 20:37:55 +00:00
Files
git-get/pkg/print/flat.go
Grzegorz Dlugoszewski 33ca245d3a Refactor pkg directory back
2020-06-12 20:19:05 +02:00

34 lines
722 B
Go

package print
import (
"fmt"
"git-get/pkg/git"
"path/filepath"
"strings"
)
type FlatPrinter struct{}
func (p *FlatPrinter) Print(root string, repos []*git.Repo) string {
val := root
for _, repo := range repos {
path := strings.TrimPrefix(repo.Path, root)
path = strings.Trim(path, string(filepath.Separator))
val += fmt.Sprintf("\n%s %s", path, printWorktreeStatus(repo))
for _, branch := range repo.Status.Branches {
// Don't print the status of the current branch. It was already printed above.
if branch.Name == repo.Status.CurrentBranch {
continue
}
indent := strings.Repeat(" ", len(path))
val += fmt.Sprintf("\n%s %s", indent, printBranchStatus(branch))
}
}
return val
}