Skip to content

Commit

Permalink
fix: pull request should be null for issues
Browse files Browse the repository at this point in the history
  • Loading branch information
msvticket committed Oct 10, 2024
1 parent 12239b8 commit 96ab517
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
22 changes: 13 additions & 9 deletions scm/driver/github/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ type issue struct {
UpdatedAt time.Time `json:"updated_at"`

// This will be non-nil if it is a pull request.
PullRequest pr `json:"pull_request,omitempty"`
PullRequest *pr `json:"pull_request,omitempty"`
}

type issueInput struct {
Expand Down Expand Up @@ -349,6 +349,13 @@ func convertIssue(from *issue) *scm.Issue {
Avatar: from.ClosedBy.AvatarURL,
}
}
var pullRequest *scm.PullRequest
if from.PullRequest != nil {
pullRequest = &scm.PullRequest{
DiffLink: from.PullRequest.DiffURL,
Link: from.PullRequest.HTMLURL,
}
}
return &scm.Issue{
Number: from.Number,
Title: from.Title,
Expand All @@ -362,14 +369,11 @@ func convertIssue(from *issue) *scm.Issue {
Login: from.User.Login,
Avatar: from.User.AvatarURL,
},
ClosedBy: closedBy,
Assignees: convertUsers(from.Assignees),
PullRequest: &scm.PullRequest{
DiffLink: from.PullRequest.DiffURL,
Link: from.PullRequest.HTMLURL,
},
Created: from.CreatedAt,
Updated: from.UpdatedAt,
ClosedBy: closedBy,
Assignees: convertUsers(from.Assignees),
PullRequest: pullRequest,
Created: from.CreatedAt,
Updated: from.UpdatedAt,
}
}

Expand Down
5 changes: 0 additions & 5 deletions scm/driver/github/testdata/issue_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@
"created_at": "2009-07-12T20:10:41Z",
"updated_at": "2009-07-19T09:23:43Z",
"closed_at": null,
"pull_request": {
"html_url": null,
"diff_url": null,
"patch_url": null
},
"body": "...",
"score": 1.3859273
}
Expand Down
5 changes: 0 additions & 5 deletions scm/driver/github/testdata/issue_search.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
"Link": "",
"Created": "0001-01-01T00:00:00Z",
"Updated": "0001-01-01T00:00:00Z"
},
"PullRequest": {
"html_url": null,
"diff_url": null,
"patch_url": null
}
}
]
5 changes: 0 additions & 5 deletions scm/driver/github/testdata/webhooks/issue_comment.json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
"Labels": [
"bug"
],
"PullRequest": {
"html_url": null,
"diff_url": null,
"patch_url": null
},
"Closed": false,
"Locked": false,
"Author": {
Expand Down

0 comments on commit 96ab517

Please sign in to comment.