From 8b1d3a056647fd319a4e09697c19970c4e764591 Mon Sep 17 00:00:00 2001 From: Herman Schaaf Date: Sun, 7 Feb 2016 00:29:43 +0800 Subject: [PATCH] Git clone -> go get --- handlers/checks.go | 36 ++++++++++++++++++++++-------------- templates/home.html | 4 ++-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/handlers/checks.go b/handlers/checks.go index 2f6c14b..9049c3b 100644 --- a/handlers/checks.go +++ b/handlers/checks.go @@ -7,6 +7,7 @@ import ( "log" "os" "os/exec" + "path/filepath" "strings" "time" @@ -86,12 +87,19 @@ func clone(url string) error { if err := os.Mkdir(fmt.Sprintf("repos/src/github.com/%s", org), 0755); err != nil && !os.IsExist(err) { return fmt.Errorf("could not create dir: %v", err) } + d, err := filepath.Abs("repos") + if err != nil { + return fmt.Errorf("could not fetch absolute path: %v", err) + } + os.Setenv("GOPATH", d) dir := dirName(url) - _, err := os.Stat(dir) + _, err = os.Stat(dir) if os.IsNotExist(err) { - cmd := exec.Command("git", "clone", "--depth", "1", "--single-branch", url, dir) + cmd := exec.Command("go", "get", "-u", url) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { - return fmt.Errorf("could not run git clone: %v", err) + return fmt.Errorf("could not run go get: %v", err) } return nil @@ -100,23 +108,23 @@ func clone(url string) error { return fmt.Errorf("could not stat dir: %v", err) } - cmd := exec.Command("git", "-C", dir, "fetch", "origin", "master") - if err := cmd.Run(); err != nil { - return fmt.Errorf("could not fetch master branch: %v", err) - } - cmd = exec.Command("git", "-C", dir, "reset", "--hard", "origin/master") - if err = cmd.Run(); err != nil { - return fmt.Errorf("could not reset origin/master: %v", err) - } + // cmd := exec.Command("git", "-C", dir, "fetch", "origin", "master") + // if err := cmd.Run(); err != nil { + // return fmt.Errorf("could not fetch master branch: %v", err) + // } + // cmd = exec.Command("git", "-C", dir, "reset", "--hard", "origin/master") + // if err = cmd.Run(); err != nil { + // return fmt.Errorf("could not reset origin/master: %v", err) + // } return nil } func newChecksResp(repo string, forceRefresh bool) (checksResp, error) { url := repo - if !strings.HasPrefix(url, "https://gojp:gojp@github.com/") { - url = "https://gojp:gojp@github.com/" + url - } + // if !strings.HasPrefix(url, "https://gojp:gojp@github.com/") { + // url = "https://gojp:gojp@github.com/" + url + // } if !forceRefresh { resp, err := getFromCache(repo) diff --git a/templates/home.html b/templates/home.html index ed2e7e7..f789ea7 100644 --- a/templates/home.html +++ b/templates/home.html @@ -158,12 +158,12 @@

- Enter the github path to the project below: + Enter the go get path to the project below:

- +