From 31d2951692a673455f2563e93357c9f43a0290a2 Mon Sep 17 00:00:00 2001 From: Songmu Date: Sat, 27 Apr 2019 23:51:36 +0900 Subject: [PATCH] rename package s/utils/cmdutil/ --- {utils => cmdutil}/run.go | 2 +- helpers_test.go | 4 ++-- remote_repository.go | 12 ++++++------ remote_repository_test.go | 6 +++--- vcs.go | 28 ++++++++++++++-------------- vcs_test.go | 12 ++++++------ 6 files changed, 32 insertions(+), 32 deletions(-) rename {utils => cmdutil}/run.go (98%) diff --git a/utils/run.go b/cmdutil/run.go similarity index 98% rename from utils/run.go rename to cmdutil/run.go index f894e9c..29853d5 100644 --- a/utils/run.go +++ b/cmdutil/run.go @@ -1,4 +1,4 @@ -package utils +package cmdutil import ( "fmt" diff --git a/helpers_test.go b/helpers_test.go index dfe4932..3e7769a 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -8,10 +8,10 @@ import ( "path/filepath" "strings" - "github.com/motemen/ghq/utils" + "github.com/motemen/ghq/cmdutil" ) -func NewFakeRunner(dispatch map[string]error) utils.RunFunc { +func NewFakeRunner(dispatch map[string]error) cmdutil.RunFunc { return func(cmd *exec.Cmd) error { cmdString := strings.Join(cmd.Args, " ") for cmdPrefix, err := range dispatch { diff --git a/remote_repository.go b/remote_repository.go index 90afabc..53cac95 100644 --- a/remote_repository.go +++ b/remote_repository.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/motemen/ghq/logger" - "github.com/motemen/ghq/utils" + "github.com/motemen/ghq/cmdutil" ) // A RemoteRepository represents a remote repository. @@ -79,9 +79,9 @@ func (repo *GoogleCodeRepository) IsValid() bool { } func (repo *GoogleCodeRepository) VCS() (*VCSBackend, *url.URL) { - if utils.RunSilently("hg", "identify", repo.url.String()) == nil { + if cmdutil.RunSilently("hg", "identify", repo.url.String()) == nil { return MercurialBackend, repo.URL() - } else if utils.RunSilently("git", "ls-remote", repo.url.String()) == nil { + } else if cmdutil.RunSilently("git", "ls-remote", repo.url.String()) == nil { return GitBackend, repo.URL() } else { return nil, nil @@ -173,7 +173,7 @@ func (repo *OtherRepository) VCS() (*VCSBackend, *url.URL) { } // Detect VCS backend automatically - if utils.RunSilently("git", "ls-remote", repo.url.String()) == nil { + if cmdutil.RunSilently("git", "ls-remote", repo.url.String()) == nil { return GitBackend, repo.URL() } @@ -183,11 +183,11 @@ func (repo *OtherRepository) VCS() (*VCSBackend, *url.URL) { return vcsRegistry[vcs], repoURL } - if utils.RunSilently("hg", "identify", repo.url.String()) == nil { + if cmdutil.RunSilently("hg", "identify", repo.url.String()) == nil { return MercurialBackend, repo.URL() } - if utils.RunSilently("svn", "info", repo.url.String()) == nil { + if cmdutil.RunSilently("svn", "info", repo.url.String()) == nil { return SubversionBackend, repo.URL() } diff --git a/remote_repository_test.go b/remote_repository_test.go index a334079..01d8ab5 100644 --- a/remote_repository_test.go +++ b/remote_repository_test.go @@ -4,7 +4,7 @@ import ( "errors" "net/url" - "github.com/motemen/ghq/utils" + "github.com/motemen/ghq/cmdutil" . "github.com/onsi/gomega" ) import "testing" @@ -72,7 +72,7 @@ func TestNewRemoteRepositoryGoogleCode(t *testing.T) { repo, err = NewRemoteRepository(parseURL("https://code.google.com/p/vim/")) Expect(err).To(BeNil()) Expect(repo.IsValid()).To(Equal(true)) - utils.CommandRunner = NewFakeRunner(map[string]error{ + cmdutil.CommandRunner = NewFakeRunner(map[string]error{ "hg identify": nil, "git ls-remote": errors.New(""), }) @@ -82,7 +82,7 @@ func TestNewRemoteRepositoryGoogleCode(t *testing.T) { repo, err = NewRemoteRepository(parseURL("https://code.google.com/p/git-core")) Expect(err).To(BeNil()) Expect(repo.IsValid()).To(Equal(true)) - utils.CommandRunner = NewFakeRunner(map[string]error{ + cmdutil.CommandRunner = NewFakeRunner(map[string]error{ "hg identify": errors.New(""), "git ls-remote": nil, }) diff --git a/vcs.go b/vcs.go index 328b95a..c1c2ce3 100644 --- a/vcs.go +++ b/vcs.go @@ -6,7 +6,7 @@ import ( "os" "path/filepath" - "github.com/motemen/ghq/utils" + "github.com/motemen/ghq/cmdutil" ) // A VCSBackend represents a VCS backend. @@ -31,10 +31,10 @@ var GitBackend = &VCSBackend{ } args = append(args, remote.String(), local) - return utils.Run("git", args...) + return cmdutil.Run("git", args...) }, Update: func(local string) error { - return utils.RunInDir(local, "git", "pull", "--ff-only") + return cmdutil.RunInDir(local, "git", "pull", "--ff-only") }, } @@ -52,10 +52,10 @@ var SubversionBackend = &VCSBackend{ } args = append(args, remote.String(), local) - return utils.Run("svn", args...) + return cmdutil.Run("svn", args...) }, Update: func(local string) error { - return utils.RunInDir(local, "svn", "update") + return cmdutil.RunInDir(local, "svn", "update") }, } @@ -68,10 +68,10 @@ var GitsvnBackend = &VCSBackend{ return err } - return utils.Run("git", "svn", "clone", remote.String(), local) + return cmdutil.Run("git", "svn", "clone", remote.String(), local) }, Update: func(local string) error { - return utils.RunInDir(local, "git", "svn", "rebase") + return cmdutil.RunInDir(local, "git", "svn", "rebase") }, } @@ -84,10 +84,10 @@ var MercurialBackend = &VCSBackend{ return err } - return utils.Run("hg", "clone", remote.String(), local) + return cmdutil.Run("hg", "clone", remote.String(), local) }, Update: func(local string) error { - return utils.RunInDir(local, "hg", "pull", "--update") + return cmdutil.RunInDir(local, "hg", "pull", "--update") }, } @@ -105,10 +105,10 @@ var DarcsBackend = &VCSBackend{ } args = append(args, remote.String(), local) - return utils.Run("darcs", args...) + return cmdutil.Run("darcs", args...) }, Update: func(local string) error { - return utils.RunInDir(local, "darcs", "pull") + return cmdutil.RunInDir(local, "darcs", "pull") }, } @@ -131,7 +131,7 @@ var FossilBackend = &VCSBackend{ return err } - err = utils.Run("fossil", "clone", remote.String(), filepath.Join(dir, fossilRepoName)) + err = cmdutil.Run("fossil", "clone", remote.String(), filepath.Join(dir, fossilRepoName)) if err != nil { return err } @@ -141,10 +141,10 @@ var FossilBackend = &VCSBackend{ return err } - return utils.Run("fossile", "open", fossilRepoName) + return cmdutil.Run("fossile", "open", fossilRepoName) }, Update: func(local string) error { - return utils.RunInDir(local, "fossil", "update") + return cmdutil.RunInDir(local, "fossil", "update") }, } diff --git a/vcs_test.go b/vcs_test.go index 6f43e2a..9fb771c 100644 --- a/vcs_test.go +++ b/vcs_test.go @@ -7,7 +7,7 @@ import ( "path/filepath" "testing" - "github.com/motemen/ghq/utils" + "github.com/motemen/ghq/cmdutil" . "github.com/onsi/gomega" ) @@ -28,7 +28,7 @@ func TestGitBackend(t *testing.T) { commands := []*exec.Cmd{} lastCommand := func() *exec.Cmd { return commands[len(commands)-1] } - utils.CommandRunner = func(cmd *exec.Cmd) error { + cmdutil.CommandRunner = func(cmd *exec.Cmd) error { commands = append(commands, cmd) return nil } @@ -76,7 +76,7 @@ func TestSubversionBackend(t *testing.T) { commands := []*exec.Cmd{} lastCommand := func() *exec.Cmd { return commands[len(commands)-1] } - utils.CommandRunner = func(cmd *exec.Cmd) error { + cmdutil.CommandRunner = func(cmd *exec.Cmd) error { commands = append(commands, cmd) return nil } @@ -124,7 +124,7 @@ func TestGitsvnBackend(t *testing.T) { commands := []*exec.Cmd{} lastCommand := func() *exec.Cmd { return commands[len(commands)-1] } - utils.CommandRunner = func(cmd *exec.Cmd) error { + cmdutil.CommandRunner = func(cmd *exec.Cmd) error { commands = append(commands, cmd) return nil } @@ -171,7 +171,7 @@ func TestMercurialBackend(t *testing.T) { commands := []*exec.Cmd{} lastCommand := func() *exec.Cmd { return commands[len(commands)-1] } - utils.CommandRunner = func(cmd *exec.Cmd) error { + cmdutil.CommandRunner = func(cmd *exec.Cmd) error { commands = append(commands, cmd) return nil } @@ -218,7 +218,7 @@ func TestDarcsBackend(t *testing.T) { commands := []*exec.Cmd{} lastCommand := func() *exec.Cmd { return commands[len(commands)-1] } - utils.CommandRunner = func(cmd *exec.Cmd) error { + cmdutil.CommandRunner = func(cmd *exec.Cmd) error { commands = append(commands, cmd) return nil }