add timeout to git clone, check length of split output

This commit is contained in:
Shawn Smith
2015-02-03 18:51:28 +09:00
parent 85f8ed4238
commit f609188d23
2 changed files with 7 additions and 5 deletions

View File

@@ -91,11 +91,13 @@ func getFileSummary(filename, dir, cmd, out string) (FileSummary, error) {
e := Error{ErrorString: msg}
switch cmd {
case "golint", "gocyclo", "vet":
ln, err := strconv.Atoi(strings.Split(sp, ":")[1])
if err != nil {
return fs, err
if len(strings.Split(sp, ":")) >= 2 {
ln, err := strconv.Atoi(strings.Split(sp, ":")[1])
if err != nil {
return fs, err
}
e.LineNumber = ln
}
e.LineNumber = ln
}
fs.Errors = append(fs.Errors, e)

View File

@@ -68,7 +68,7 @@ func clone(url string) error {
dir := dirName(url)
_, err := os.Stat(dir)
if os.IsNotExist(err) {
cmd := exec.Command("git", "clone", "--depth", "1", "--single-branch", url, dir)
cmd := exec.Command("timeout", "git", "clone", "--depth", "1", "--single-branch", url, dir)
if err := cmd.Run(); err != nil {
return fmt.Errorf("could not run git clone: %v", err)
}