mirror of
https://github.com/x-motemen/ghq.git
synced 2026-09-10 07:26:27 -04:00
adjustment
This commit is contained in:
parent
67a22bf1f7
commit
ef0d942544
28
cmd_root.go
28
cmd_root.go
|
|
@ -7,24 +7,20 @@ import (
|
|||
)
|
||||
|
||||
func doRoot(c *cli.Context) error {
|
||||
var (
|
||||
w = c.App.Writer
|
||||
all = c.Bool("all")
|
||||
)
|
||||
if all {
|
||||
roots, err := localRepositoryRoots(true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, root := range roots {
|
||||
fmt.Fprintln(w, root)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
root, err := primaryLocalRepositoryRoot()
|
||||
roots, err := localRepositoryRoots(true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintln(w, root)
|
||||
if !c.Bool("all") {
|
||||
roots = roots[:1] // only the first root is needed
|
||||
}
|
||||
|
||||
for _, root := range roots {
|
||||
_, err := fmt.Fprintln(c.App.Writer, root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,10 +117,10 @@ func LocalRepositoryFromURL(remoteURL *url.URL) (*LocalRepository, error) {
|
|||
|
||||
func getRoot(u string) (string, error) {
|
||||
prim := os.Getenv(envGhqRoot)
|
||||
var err error
|
||||
if prim != "" {
|
||||
return prim, nil
|
||||
}
|
||||
var err error
|
||||
if !codecommitLikeURLPattern.MatchString(u) {
|
||||
prim, err = gitconfig.Do("--path", "--get-urlmatch", "ghq.root", u)
|
||||
if err != nil && !gitconfig.IsNotFound(err) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue