Skip to content
This repository has been archived by the owner on May 29, 2018. It is now read-only.

Commit

Permalink
Fix srclib installation directory
Browse files Browse the repository at this point in the history
And remove (now unused) srclib.PathEntries
  • Loading branch information
rothfels committed Oct 12, 2015
1 parent 39e8fa6 commit 4666f13
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
9 changes: 0 additions & 9 deletions env.go
Expand Up @@ -5,8 +5,6 @@ import (
"os"
"path/filepath"

"strings"

"sourcegraph.com/sourcegraph/srclib/util"
)

Expand All @@ -27,13 +25,6 @@ var (
CommandName = "srclib"
)

// PathEntries returns first colon-separated entries in Path
// (SRCLIBPATH). It is guaranteed to have at least one non-empty
// element.
func PathEntries() []string {
return strings.Split(Path, ":")
}

func init() {
if Path == "" {
homeDir := util.CurrentUserHomeDir()
Expand Down
14 changes: 7 additions & 7 deletions toolchain/get.go
Expand Up @@ -5,8 +5,6 @@ import (
"os"
"os/exec"
"path/filepath"

"sourcegraph.com/sourcegraph/srclib"
)

// CloneOrUpdate downloads the toolchain named by the toolchain path
Expand All @@ -17,19 +15,21 @@ import (
func CloneOrUpdate(path string, update bool) (*Info, error) {
path = filepath.Clean(path)

dir := filepath.SplitList(srclib.Path)[0]
toolchainDir := filepath.Join(dir, path)
dir, err := Dir(path)
if err != nil {
return nil, err
}

if fi, err := os.Stat(toolchainDir); os.IsNotExist(err) {
if fi, err := os.Stat(dir); os.IsNotExist(err) {
cloneURL := "https://" + path + ".git"
cmd := exec.Command("git", "clone", cloneURL, toolchainDir)
cmd := exec.Command("git", "clone", cloneURL, dir)
cmd.Stdout, cmd.Stderr = os.Stderr, os.Stderr
if err := cmd.Run(); err != nil {
return nil, err
}
} else if update && fi.Mode().IsDir() {
cmd := exec.Command("git", "pull", "origin", "master")
cmd.Dir = toolchainDir
cmd.Dir = dir
cmd.Stdout, cmd.Stderr = os.Stderr, os.Stderr
if err := cmd.Run(); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion toolchain/toolchain.go
Expand Up @@ -24,7 +24,7 @@ func Dir(toolchainPath string) (string, error) {

dir, err := lookupToolchain(toolchainPath)
if os.IsNotExist(err) {
return filepath.Join(srclib.PathEntries()[0], toolchainPath), nil
return filepath.Join(filepath.SplitList(srclib.Path)[0], toolchainPath), nil
}
if err != nil {
err = &os.PathError{Op: "toolchain.Dir", Path: toolchainPath, Err: err}
Expand Down

0 comments on commit 4666f13

Please sign in to comment.