Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmd_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"
"sync"

"github.com/Songmu/gitconfig"
"github.com/mattn/go-isatty"
"github.com/urfave/cli/v2"
"github.com/x-motemen/ghq/cmdutil"
Expand All @@ -26,6 +27,15 @@ func doGet(c *cli.Context) error {
parallel = c.Bool("parallel")
silent = c.Bool("silent")
)
if !andLook {
v, err := gitconfig.Bool("ghq.look")
if err != nil && !gitconfig.IsNotFound(err) {
return err
}
if err == nil {
andLook = v
}
}
g := &getter{
update: c.Bool("update"),
shallow: c.Bool("shallow"),
Expand Down
25 changes: 25 additions & 0 deletions cmd_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,31 @@ func TestBareLook(t *testing.T) {
})
}

func TestLookFromGitConfig(t *testing.T) {
withFakeGitBackend(t, func(t *testing.T, tmproot string, _ *_cloneArgs, _ *_updateArgs) {
os.MkdirAll(filepath.Join(tmproot, "github.com", "motemen", "ghq", ".git"), 0755)
defer func(orig func(cmd *exec.Cmd) error) {
cmdutil.CommandRunner = orig
}(cmdutil.CommandRunner)
var lastCmd *exec.Cmd
cmdutil.CommandRunner = func(cmd *exec.Cmd) error {
lastCmd = cmd
return nil
}

t.Cleanup(gitconfig.WithConfig(t, `[ghq]
look = true
`))
err := newApp().Run([]string{"", "get", "https://github.com/motemen/ghq"})
if err != nil {
t.Errorf("error should be nil, but: %s", err)
}
if lastCmd == nil {
t.Fatal("shell should have been launched")
}
})
}

func TestDoGet_bulk(t *testing.T) {
in := []string{
"github.com/x-motemen/ghq",
Expand Down