Skip to content

Commit

Permalink
fix panic when timeout is nil in gitlab cloneOptions (#1016)
Browse files Browse the repository at this point in the history
Co-authored-by: jackyu <[email protected]>
  • Loading branch information
ks-ci-bot and yudong2015 authored Oct 26, 2023
1 parent 6afb8d9 commit 520ede6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/client/devops/jenkins/internal/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ func GetGitlabSourceFromEtree(source *etree.Element) (gitSource *devopsv1alpha3.
if value, err := strconv.ParseBool(cloneExtension.SelectElement("shallow").Text()); err == nil {
gitSource.CloneOption.Shallow = value
}
if value, err := strconv.ParseInt(cloneExtension.SelectElement("timeout").Text(), 10, 32); err == nil {
gitSource.CloneOption.Timeout = int(value)
if timeout := cloneExtension.SelectElement("timeout"); timeout != nil {
if value, err := strconv.ParseInt(timeout.Text(), 10, 32); err == nil {
gitSource.CloneOption.Timeout = int(value)
}
}
if value, err := strconv.ParseInt(cloneExtension.SelectElement("depth").Text(), 10, 32); err == nil {
gitSource.CloneOption.Depth = int(value)
if depth := cloneExtension.SelectElement("depth"); depth != nil {
if value, err := strconv.ParseInt(depth.Text(), 10, 32); err == nil {
gitSource.CloneOption.Depth = int(value)
}
}
}
}
Expand Down

0 comments on commit 520ede6

Please sign in to comment.