提交 e0b66f06 编写于 作者: J Jingwen Owen Ou

Remove sysexec since Windows doesn't support it…:-(

上级 edabaedb
......@@ -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)}
}
......
......@@ -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)
}
......@@ -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
}
......
......@@ -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)
......
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册