Skip to content

Commit

Permalink
Merge pull request #122 from Revolyssup/gitclone
Browse files Browse the repository at this point in the history
Handled potential panic in one of the cases in gitwalker
  • Loading branch information
tangledbytes authored Oct 28, 2021
2 parents d6a0301 + a970465 commit 65a23b9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions utils/walker/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,18 @@ func clonewalk(g *Git) error {

path := filepath.Join(os.TempDir(), g.repo, strconv.FormatInt(time.Now().UTC().UnixNano(), 10))
defer os.RemoveAll(path)
logs := os.Stdout
if !g.showLogs {
logs = nil
var err error
if g.showLogs {
_, err = git.PlainClone(path, false, &git.CloneOptions{
URL: fmt.Sprintf("%s/%s/%s", g.baseURL, g.owner, g.repo),
Progress: os.Stdout,
})
} else {
_, err = git.PlainClone(path, false, &git.CloneOptions{
URL: fmt.Sprintf("%s/%s/%s", g.baseURL, g.owner, g.repo),
})
}
_, err := git.PlainClone(path, false, &git.CloneOptions{
URL: fmt.Sprintf("%s/%s/%s", g.baseURL, g.owner, g.repo),
Progress: logs,
})

if err != nil {
return ErrCloningRepo(err)
}
Expand Down Expand Up @@ -192,7 +196,9 @@ func clonewalk(g *Git) error {
return nil
}
err := g.readFile(f, path)
fmt.Println(err.Error())
if err != nil {
fmt.Println(err.Error())
}
}

return nil
Expand Down

0 comments on commit 65a23b9

Please sign in to comment.