Skip to content

Commit

Permalink
Remove sysexec since Windows doesn't support it…:-(
Browse files Browse the repository at this point in the history
  • Loading branch information
owenthereal committed Sep 20, 2013
1 parent f05a85f commit d527efb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 40 deletions.
15 changes: 0 additions & 15 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"os/exec"
"strings"
"syscall"
)

type Cmd struct {
Expand Down Expand Up @@ -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)}
}
Expand Down
2 changes: 1 addition & 1 deletion commands/browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
13 changes: 3 additions & 10 deletions commands/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
Expand Down
10 changes: 0 additions & 10 deletions git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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) {
Expand Down

0 comments on commit d527efb

Please sign in to comment.