From d527efb3f83de97c111dd2a2867e72aaa4cd5678 Mon Sep 17 00:00:00 2001 From: Jingwen Owen Ou Date: Fri, 20 Sep 2013 15:13:11 -0700 Subject: [PATCH] =?UTF-8?q?Remove=20sysexec=20since=20Windows=20doesn't=20?= =?UTF-8?q?support=20it=E2=80=A6:-(?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/cmd.go | 15 --------------- commands/browse.go | 2 +- commands/runner.go | 13 +++---------- git/git.go | 10 ---------- github/github.go | 8 ++++---- 5 files changed, 8 insertions(+), 40 deletions(-) diff --git a/cmd/cmd.go b/cmd/cmd.go index 8a7da3b..cb29f68 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -5,7 +5,6 @@ import ( "os" "os/exec" "strings" - "syscall" ) type Cmd struct { @@ -53,20 +52,6 @@ func (cmd *Cmd) Exec() error { return c.Run() } -func (cmd *Cmd) SysExec() error { - binary, lookErr := exec.LookPath(cmd.Name) - if lookErr != nil { - return fmt.Errorf("command not found: %s", cmd.Name) - } - - args := []string{cmd.Name} - args = append(args, cmd.Args...) - - env := os.Environ() - - return syscall.Exec(binary, args, env) -} - func New(name string) *Cmd { return &Cmd{Name: name, Args: make([]string, 0)} } diff --git a/commands/browse.go b/commands/browse.go index 55a7a99..7695bae 100644 --- a/commands/browse.go +++ b/commands/browse.go @@ -64,6 +64,6 @@ func browse(command *Command, args *Args) { utils.Check(err) } - args.Replace(launcher[0], "", launcher[1:]...) + args.Replace(launcher[0], "", launcher[1:]...) args.AppendParams(url) } diff --git a/commands/runner.go b/commands/runner.go index 7da2238..ab30bc2 100644 --- a/commands/runner.go +++ b/commands/runner.go @@ -54,7 +54,7 @@ func (r *Runner) Execute() error { } } - return git.SysExec(args.Command, args.Params...) + return git.Spawn(args.Command, args.Params...) } func slurpGlobalFlags(args *Args) { @@ -73,15 +73,8 @@ func printCommands(cmds []*cmd.Cmd) { } func executeCommands(cmds []*cmd.Cmd) error { - length := len(cmds) - for i, c := range cmds { - var err error - if i == (length - 1) { - err = c.SysExec() - } else { - err = c.Exec() - } - + for _, c := range cmds { + err := c.Exec() if err != nil { return err } diff --git a/git/git.go b/git/git.go index e9b5859..4c215e4 100644 --- a/git/git.go +++ b/git/git.go @@ -116,16 +116,6 @@ func Config(name string) (string, error) { return output[0], nil } -func SysExec(command string, args ...string) error { - cmd := cmd.New("git") - cmd.WithArg(command) - for _, a := range args { - cmd.WithArg(a) - } - - return cmd.SysExec() -} - func Spawn(command string, args ...string) error { cmd := cmd.New("git") cmd.WithArg(command) diff --git a/github/github.go b/github/github.go index 65f8cfe..7bf1102 100644 --- a/github/github.go +++ b/github/github.go @@ -59,7 +59,7 @@ func (gh *GitHub) CreateRepository(project Project, description, homepage string func (gh *GitHub) CreatePullRequestForIssue(base, head, issue string) (string, error) { client := gh.client() - params := octokat.PullRequestForIssueParams{Base: base, Head: head, Issue: issue} + params := octokat.PullRequestForIssueParams{Base: base, Head: head, Issue: issue} pullRequest, err := client.CreatePullRequestForIssue(gh.repo(), params) if err != nil { return "", err @@ -85,14 +85,14 @@ func (gh *GitHub) CiStatus(sha string) (*octokat.Status, error) { func (gh *GitHub) ForkRepository(name, owner string, noRemote bool) (repo *octokat.Repository, err error) { client := gh.client() config := gh.Config - repo, err = client.Repository(octokat.Repo{Name: name, UserName: config.User}) + repo, err = client.Repository(octokat.Repo{Name: name, UserName: config.User}) if repo != nil && err == nil { msg := fmt.Sprintf("Error creating fork: %s exists on %s", repo.FullName, GitHubHost) err = errors.New(msg) return } - repo, err = client.Fork(octokat.Repo{Name: name, UserName: owner}, nil) + repo, err = client.Fork(octokat.Repo{Name: name, UserName: owner}, nil) return } @@ -109,7 +109,7 @@ func (gh *GitHub) ExpandRemoteUrl(owner, name string, isSSH bool) (url string) { func (gh *GitHub) repo() octokat.Repo { project := gh.Project - return octokat.Repo{Name: project.Name, UserName: project.Owner} + return octokat.Repo{Name: project.Name, UserName: project.Owner} } func findOrCreateToken(user, password string) (string, error) {