This commit is contained in:
Keita Shimura 2026-08-23 00:07:05 +02:00 committed by GitHub
commit 40d11cb842
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 0 deletions

View file

@ -13,6 +13,7 @@ import (
"strings"
"sync"
"github.com/Songmu/gitconfig"
"github.com/mattn/go-isatty"
"github.com/urfave/cli/v3"
"github.com/x-motemen/ghq/cmdutil"
@ -27,6 +28,15 @@ func doGet(ctx context.Context, cmd *cli.Command) error {
parallel = cmd.Bool("parallel")
silent = cmd.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: cmd.Bool("update"),
shallow: cmd.Bool("shallow"),

View file

@ -497,6 +497,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",