Skip to content

Commit cdb1453

Browse files
committed
Release 3.0.4
1 parent b903429 commit cdb1453

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,7 @@
7575
## 3.0.3
7676

7777
- Update Flutter checker to ignore overridden dependencies.
78+
79+
## 3.0.4
80+
81+
- If style violation is not part of the review diff, create a pull request comment.

lib/src/reporters/github/github_api_service.dart

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,40 @@ class GithubApiService {
103103
final int violationLineInDiff =
104104
await findViolationLineInFileDiff(fileDiff?.patch, violation.line);
105105

106-
final Map<String, dynamic> reviewComment = <String, dynamic>{
107-
'path': fileDiff?.filename,
108-
'line': violation.line,
109-
'position': violationLineInDiff,
110-
'commit_id': commitId,
111-
'body': formatViolationMessage(violation)
112-
};
113-
114-
final http.Response response = await http.post(
115-
Uri.parse(
116-
'$baseUrl/repos/$repoOwner/$repoName/pulls/$pullRequestId/comments',
117-
),
118-
headers: headers,
119-
body: json.encode(reviewComment),
120-
);
106+
final http.Response response;
107+
108+
if (violationLineInDiff > 0) {
109+
final Map<String, dynamic> reviewComment = <String, dynamic>{
110+
'path': fileDiff?.filename,
111+
'line': violationLineInDiff,
112+
'commit_id': commitId,
113+
'body': formatViolationMessage(violation)
114+
};
115+
116+
response = await http.post(
117+
Uri.parse(
118+
'$baseUrl/repos/$repoOwner/$repoName/pulls/$pullRequestId/comments',
119+
),
120+
headers: headers,
121+
body: json.encode(reviewComment),
122+
);
123+
} else {
124+
final Map<String, dynamic> pullRequestComment = <String, dynamic>{
125+
'commit_id': commitId,
126+
'event': 'COMMENT',
127+
'body': formatViolationMessage(violation),
128+
};
129+
130+
response = await http.post(
131+
Uri.parse(
132+
'$baseUrl/repos/$repoOwner/$repoName/pulls/$pullRequestId/reviews',
133+
),
134+
headers: headers,
135+
body: json.encode(pullRequestComment),
136+
);
137+
}
121138

122-
if (response.statusCode != 201) {
139+
if (response.statusCode != 201 && response.statusCode != 200) {
123140
throw UnrecoverableException(
124141
'Could not add review comment: ${response.body}',
125142
exitGithubApiError,

pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dbstyleguidechecker
2-
description: A tool that help you verify a project agains code style guide and automatize pull request review.
3-
version: 3.0.3
2+
description: A tool that help you verify a project against code style guide and automatize pull request review.
3+
version: 3.0.4
44
homepage: https://github.com/bitsydarel/dbstyleguidechecker
55
repository: https://github.com/bitsydarel/dbstyleguidechecker
66
issue_tracker: https://github.com/bitsydarel/dbstyleguidechecker/issues
@@ -9,9 +9,9 @@ environment:
99
sdk: '>=2.18.1 <3.0.0'
1010

1111
dependencies:
12-
args: ^2.2.0
12+
args: '>=2.2.0 <2.4.0'
1313
http: '>=0.13.4 <0.15.0'
14-
io: ^1.0.3
14+
io: '>=1.0.3 <1.1.0'
1515
meta: '>=1.3.0 <2.0.0'
1616
path: '>=1.8.0 <2.0.0'
1717

0 commit comments

Comments
 (0)