Skip to content

Commit 20588d0

Browse files
Add node_id to the pull request model (#367)
1 parent 3771b3c commit 20588d0

File tree

3 files changed

+252
-0
lines changed

3 files changed

+252
-0
lines changed

lib/src/common/model/pulls.dart

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ part 'pulls.g.dart';
99
class PullRequest {
1010
PullRequest({
1111
this.id,
12+
this.nodeId,
1213
this.htmlUrl,
1314
this.diffUrl,
1415
this.patchUrl,
@@ -46,6 +47,9 @@ class PullRequest {
4647
/// Pull Request ID
4748
int? id;
4849

50+
/// Unique node identification string.
51+
String? nodeId;
52+
4953
/// Url to the Pull Request Page
5054
String? htmlUrl;
5155

lib/src/common/model/pulls.g.dart

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+246
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
import 'dart:convert';
2+
3+
import 'package:github/src/common/model/pulls.dart';
4+
import 'package:test/test.dart';
5+
6+
const String samplePullRequest = '''
7+
{
8+
"url": "https://api.github.com/repos/flutter/cocoon/pulls/2703",
9+
"id": 1344460863,
10+
"node_id": "PR_kwDOA8VHis5QItg_",
11+
"html_url": "https://github.com/flutter/cocoon/pull/2703",
12+
"diff_url": "https://github.com/flutter/cocoon/pull/2703.diff",
13+
"patch_url": "https://github.com/flutter/cocoon/pull/2703.patch",
14+
"issue_url": "https://api.github.com/repos/flutter/cocoon/issues/2703",
15+
"number": 2703,
16+
"state": "open",
17+
"locked": false,
18+
"title": "Bump url_launcher from 6.1.10 to 6.1.11 in /dashboard",
19+
"user": {
20+
"login": "dependabot[bot]",
21+
"id": 49699333,
22+
"node_id": "MDM6Qm90NDk2OTkzMzM=",
23+
"avatar_url": "https://avatars.githubusercontent.com/in/29110?v=4",
24+
"gravatar_id": "",
25+
"url": "https://api.github.com/users/dependabot%5Bbot%5D",
26+
"html_url": "https://github.com/apps/dependabot",
27+
"type": "Bot",
28+
"site_admin": false
29+
},
30+
"body": "Bumps [url_launcher](https://github.com/flutter/packages/tree/main/packages/url_launcher) from 6.1.10 to 6.1.11.",
31+
"created_at": "2023-05-09T22:23:34Z",
32+
"updated_at": "2023-05-09T22:23:35Z",
33+
"closed_at": null,
34+
"merged_at": null,
35+
"merge_commit_sha": "252a1a4370e30631b090eeeda182879985cc8f08",
36+
"assignee": null,
37+
"assignees": [
38+
39+
],
40+
"requested_reviewers": [
41+
42+
],
43+
"requested_teams": [
44+
45+
],
46+
"labels": [
47+
{
48+
"id": 3960015931,
49+
"node_id": "LA_kwDOA8VHis7sCQw7",
50+
"url": "https://api.github.com/repos/flutter/cocoon/labels/autosubmit",
51+
"name": "autosubmit",
52+
"color": "0E8A16",
53+
"default": false,
54+
"description": "Merge PR when tree becomes green via auto submit App"
55+
}
56+
],
57+
"milestone": null,
58+
"draft": false,
59+
"commits_url": "https://api.github.com/repos/flutter/cocoon/pulls/2703/commits",
60+
"review_comments_url": "https://api.github.com/repos/flutter/cocoon/pulls/2703/comments",
61+
"review_comment_url": "https://api.github.com/repos/flutter/cocoon/pulls/comments{/number}",
62+
"comments_url": "https://api.github.com/repos/flutter/cocoon/issues/2703/comments",
63+
"statuses_url": "https://api.github.com/repos/flutter/cocoon/statuses/57ec5a040c8a631e39b3f3dee82a77fdf79b6e19",
64+
"head": {
65+
"label": "flutter:dependabot/pub/dashboard/url_launcher-6.1.11",
66+
"ref": "dependabot/pub/dashboard/url_launcher-6.1.11",
67+
"sha": "57ec5a040c8a631e39b3f3dee82a77fdf79b6e19",
68+
"user": {
69+
"login": "flutter",
70+
"id": 14101776,
71+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE0MTAxNzc2",
72+
"avatar_url": "https://avatars.githubusercontent.com/u/14101776?v=4",
73+
"gravatar_id": "",
74+
"url": "https://api.github.com/users/flutter",
75+
"html_url": "https://github.com/flutter",
76+
"type": "Organization",
77+
"site_admin": false
78+
},
79+
"repo": {
80+
"id": 63260554,
81+
"node_id": "MDEwOlJlcG9zaXRvcnk2MzI2MDU1NA==",
82+
"name": "cocoon",
83+
"full_name": "flutter/cocoon",
84+
"private": false,
85+
"owner": {
86+
"login": "flutter",
87+
"id": 14101776,
88+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE0MTAxNzc2",
89+
"avatar_url": "https://avatars.githubusercontent.com/u/14101776?v=4",
90+
"gravatar_id": "",
91+
"url": "https://api.github.com/users/flutter",
92+
"html_url": "https://github.com/flutter",
93+
"type": "Organization",
94+
"site_admin": false
95+
},
96+
"html_url": "https://github.com/flutter/cocoon",
97+
"description": "Flutter's build coordinator and aggregator",
98+
"fork": false,
99+
"url": "https://api.github.com/repos/flutter/cocoon",
100+
"forks_url": "https://api.github.com/repos/flutter/cocoon/forks",
101+
"created_at": "2016-07-13T16:04:04Z",
102+
"updated_at": "2023-04-12T16:34:46Z",
103+
"pushed_at": "2023-05-09T22:23:35Z",
104+
"git_url": "git://github.com/flutter/cocoon.git",
105+
"ssh_url": "git@github.com:flutter/cocoon.git",
106+
"clone_url": "https://github.com/flutter/cocoon.git",
107+
"svn_url": "https://github.com/flutter/cocoon",
108+
"homepage": null,
109+
"size": 13247,
110+
"stargazers_count": 171,
111+
"watchers_count": 171,
112+
"license": {
113+
"key": "bsd-3-clause",
114+
"name": "BSD 3-Clause New or Revised License",
115+
"spdx_id": "BSD-3-Clause",
116+
"url": "https://api.github.com/licenses/bsd-3-clause",
117+
"node_id": "MDc6TGljZW5zZTU="
118+
},
119+
"allow_forking": true,
120+
"is_template": false,
121+
"web_commit_signoff_required": false,
122+
"topics": [
123+
124+
],
125+
"visibility": "public",
126+
"forks": 91,
127+
"open_issues": 2,
128+
"watchers": 171,
129+
"default_branch": "main",
130+
"allow_squash_merge": true,
131+
"allow_merge_commit": false,
132+
"allow_rebase_merge": false,
133+
"allow_auto_merge": false,
134+
"delete_branch_on_merge": false,
135+
"allow_update_branch": false,
136+
"use_squash_pr_title_as_default": true,
137+
"squash_merge_commit_message": "PR_BODY",
138+
"squash_merge_commit_title": "PR_TITLE",
139+
"merge_commit_message": "PR_TITLE",
140+
"merge_commit_title": "MERGE_MESSAGE"
141+
}
142+
},
143+
"base": {
144+
"label": "flutter:main",
145+
"ref": "main",
146+
"sha": "152dd99368b8417b2ede8ed49d5923e594a3b0f2",
147+
"user": {
148+
"login": "flutter",
149+
"id": 14101776,
150+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE0MTAxNzc2",
151+
"avatar_url": "https://avatars.githubusercontent.com/u/14101776?v=4",
152+
"gravatar_id": "",
153+
"url": "https://api.github.com/users/flutter",
154+
"html_url": "https://github.com/flutter",
155+
"type": "Organization",
156+
"site_admin": false
157+
},
158+
"repo": {
159+
"id": 63260554,
160+
"node_id": "MDEwOlJlcG9zaXRvcnk2MzI2MDU1NA==",
161+
"name": "cocoon",
162+
"full_name": "flutter/cocoon",
163+
"private": false,
164+
"owner": {
165+
"login": "flutter",
166+
"id": 14101776,
167+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE0MTAxNzc2",
168+
"avatar_url": "https://avatars.githubusercontent.com/u/14101776?v=4",
169+
"gravatar_id": "",
170+
"url": "https://api.github.com/users/flutter",
171+
"html_url": "https://github.com/flutter",
172+
"type": "Organization",
173+
"site_admin": false
174+
},
175+
"html_url": "https://github.com/flutter/cocoon",
176+
"description": "Flutter's build coordinator and aggregator",
177+
"fork": false,
178+
"url": "https://api.github.com/repos/flutter/cocoon",
179+
"forks_url": "https://api.github.com/repos/flutter/cocoon/forks",
180+
"created_at": "2016-07-13T16:04:04Z",
181+
"updated_at": "2023-04-12T16:34:46Z",
182+
"pushed_at": "2023-05-09T22:23:35Z",
183+
"git_url": "git://github.com/flutter/cocoon.git",
184+
"ssh_url": "git@github.com:flutter/cocoon.git",
185+
"clone_url": "https://github.com/flutter/cocoon.git",
186+
"svn_url": "https://github.com/flutter/cocoon",
187+
"homepage": null,
188+
"size": 13247,
189+
"license": {
190+
"key": "bsd-3-clause",
191+
"name": "BSD 3-Clause New or Revised License",
192+
"spdx_id": "BSD-3-Clause",
193+
"url": "https://api.github.com/licenses/bsd-3-clause",
194+
"node_id": "MDc6TGljZW5zZTU="
195+
},
196+
"allow_forking": true,
197+
"is_template": false,
198+
"web_commit_signoff_required": false,
199+
"topics": [
200+
201+
],
202+
"visibility": "public",
203+
"forks": 91,
204+
"open_issues": 2,
205+
"watchers": 171,
206+
"default_branch": "main",
207+
"allow_squash_merge": true,
208+
"allow_merge_commit": false,
209+
"allow_rebase_merge": false,
210+
"allow_auto_merge": false,
211+
"delete_branch_on_merge": false,
212+
"allow_update_branch": false,
213+
"use_squash_pr_title_as_default": true,
214+
"squash_merge_commit_message": "PR_BODY",
215+
"squash_merge_commit_title": "PR_TITLE",
216+
"merge_commit_message": "PR_TITLE",
217+
"merge_commit_title": "MERGE_MESSAGE"
218+
}
219+
},
220+
"author_association": "CONTRIBUTOR",
221+
"auto_merge": null,
222+
"active_lock_reason": null,
223+
"merged": false,
224+
"mergeable": true,
225+
"rebaseable": true,
226+
"mergeable_state": "unstable",
227+
"merged_by": null,
228+
"comments": 0,
229+
"review_comments": 0,
230+
"maintainer_can_modify": false,
231+
"commits": 1,
232+
"additions": 119,
233+
"deletions": 202,
234+
"changed_files": 2
235+
}
236+
''';
237+
238+
void main() {
239+
group('Pull Request fromJson', () {
240+
test('Node ID is collected', () {
241+
final pullRequest = PullRequest.fromJson(jsonDecode(samplePullRequest));
242+
expect(pullRequest, isNotNull);
243+
expect(pullRequest.nodeId, "PR_kwDOA8VHis5QItg_");
244+
});
245+
});
246+
}

0 commit comments

Comments
 (0)