From 100c9f9a473f036f65df6a11a08dce957a4d2e2f Mon Sep 17 00:00:00 2001 From: tariqibrahim Date: Mon, 18 Sep 2017 23:48:03 -0400 Subject: [PATCH] Renaming repos directory to _repos as per issue #203 and updating travis yml --- .travis.yml | 1 + check/utils.go | 10 +++++----- handlers/checks.go | 4 ++-- handlers/checks_test.go | 2 +- main.go | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index b16a549..b8f567d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: go go: - 1.8 + - 1.9 - tip install: diff --git a/check/utils.go b/check/utils.go index b88fa05..d9249f4 100644 --- a/check/utils.go +++ b/check/utils.go @@ -216,7 +216,7 @@ func goPkgInToGitHub(name string) string { func fileURL(dir, filename string) string { var fileURL string - base := strings.TrimPrefix(dir, "repos/src/") + base := strings.TrimPrefix(dir, "_repos/src/") switch { case strings.HasPrefix(base, "golang.org/x/"): var pkg string @@ -263,14 +263,14 @@ func getFileSummaryMap(out *bufio.Scanner, dir string) (map[string]FileSummary, outer: for out.Scan() { filename := strings.Split(out.Text(), ":")[0] - filename = strings.TrimPrefix(filename, "repos/src") + filename = strings.TrimPrefix(filename, "_repos/src") for _, skip := range skipSuffixes { if strings.HasSuffix(filename, skip) { continue outer } } - if autoGenerated("repos/src" + filename) { + if autoGenerated("_repos/src" + filename) { continue outer } @@ -391,10 +391,10 @@ func GoFmtNative(dir string, filenames []string) (float64, []FileSummary, error) errChan <- err } if !bytes.Equal(b, g) { - filename := strings.TrimPrefix(f, "repos/src") + filename := strings.TrimPrefix(f, "_repos/src") fs := FileSummary{} fs.Filename = makeFilename(filename) - fu := fileURL(dir, strings.TrimPrefix(f, "repos/src")) + fu := fileURL(dir, strings.TrimPrefix(f, "_repos/src")) fs.FileURL = fu fs.Errors = append(fs.Errors, Error{1, "file is not gofmted"}) diff --git a/handlers/checks.go b/handlers/checks.go index bdb26d5..0f27cdf 100644 --- a/handlers/checks.go +++ b/handlers/checks.go @@ -15,7 +15,7 @@ import ( ) func dirName(repo string) string { - return fmt.Sprintf("repos/src/%s", repo) + return fmt.Sprintf("_repos/src/%s", repo) } func getFromCache(repo string) (checksResp, error) { @@ -87,7 +87,7 @@ func newChecksResp(repo string, forceRefresh bool) (checksResp, error) { } // fetch the repo and grade it - repoRoot, err := download.Download(repo, "repos/src") + repoRoot, err := download.Download(repo, "_repos/src") if err != nil { return checksResp{}, fmt.Errorf("could not clone repo: %v", err) } diff --git a/handlers/checks_test.go b/handlers/checks_test.go index b53ee38..7b819c0 100644 --- a/handlers/checks_test.go +++ b/handlers/checks_test.go @@ -6,7 +6,7 @@ var dirNameTests = []struct { url string want string }{ - {"github.com/foo/bar", "repos/src/github.com/foo/bar"}, + {"github.com/foo/bar", "_repos/src/github.com/foo/bar"}, } func TestDirName(t *testing.T) { diff --git a/main.go b/main.go index adcc829..2ba4433 100644 --- a/main.go +++ b/main.go @@ -78,7 +78,7 @@ func initDB() error { func main() { flag.Parse() - if err := os.MkdirAll("repos/src/github.com", 0755); err != nil && !os.IsExist(err) { + if err := os.MkdirAll("_repos/src/github.com", 0755); err != nil && !os.IsExist(err) { log.Fatal("ERROR: could not create repos dir: ", err) }