Skip to content

Commit

Permalink
Update pkg/vcs/github_client/client.go
Browse files Browse the repository at this point in the history
Co-authored-by: Joseph Lombrozo <[email protected]>
Signed-off-by: AvivGuiser <[email protected]>
  • Loading branch information
KyriosGN0 and djeebus authored Oct 2, 2024
1 parent fc757b7 commit bd0e151
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions pkg/vcs/github_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,9 @@ func (c *Client) buildRepoFromEvent(event *github.PullRequestEvent) vcs.PullRequ

// buildRepoFromComment builds a vcs.PullRequest from a github.IssueCommentEvent
func (c *Client) buildRepoFromComment(context context.Context, comment *github.IssueCommentEvent) vcs.PullRequest {
prURL, err := url.Parse(comment.Issue.GetURL())
if err != nil {
log.Error().Msgf("failed to parse pr url: %+v", prURL)
return nilPr
}
pathSegments := strings.Split(prURL.Path, "/")
if len(pathSegments) < 5 {
// invalid path, return nilPr
log.Error().Msgf("invalid pr url path: %s", prURL.Path)
return nilPr
}
owner := pathSegments[2]
repo := pathSegments[3]
prNumber, err := strconv.Atoi(pathSegments[4])
owner := comment.GetIssue().GetRepository().GetOwner().GetName()
repo := comment.GetIssue().GetRepository().GetName()
prNumber := comment.GetIssue().GetNumber()
if err != nil {
log.Error().Msgf("failed to convert prNumber: %s", err)
return nilPr
Expand Down

0 comments on commit bd0e151

Please sign in to comment.