Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
add more detail to patch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
owenrumney committed Jan 21, 2022
1 parent 888431d commit 00a96c0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions commenter/commenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,21 @@ func buildComment(file, comment string, line int, info commitFileInfo) *github.P
}

func getCommitInfo(file *github.CommitFile) (*commitFileInfo, error) {
patch := file.GetPatch()
if patch == "" {
return nil, nil
}

groups := patchRegex.FindAllStringSubmatch(file.GetPatch(), -1)
if len(groups) < 1 {
return nil, errors.New("the patch details could not be resolved")
return nil, fmt.Errorf("the patch details for [%s] could not be resolved", *file.Filename)
}
hunkStart, _ := strconv.Atoi(groups[0][1])
hunkEnd, _ := strconv.Atoi(groups[0][2])

shaGroups := commitRefRegex.FindAllStringSubmatch(file.GetContentsURL(), -1)
if len(shaGroups) < 1 {
return nil, errors.New("the sha details could not be resolved")
return nil, fmt.Errorf("the sha details for [%s] could not be resolved", *file.Filename)
}
sha := shaGroups[0][1]

Expand Down

0 comments on commit 00a96c0

Please sign in to comment.