mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-29 06:49:05 +08:00
add timeout to git clone, check length of split output
This commit is contained in:
@@ -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)
|
||||
|
||||
2
main.go
2
main.go
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user