|
37 | 37 | retry="retry-after", |
38 | 38 | ) |
39 | 39 |
|
40 | | -QUERY_REVIEW_COMMENTS = """ |
41 | | - query($owner: String!, $name: String!, $number: Int!) { |
| 40 | +QUERY_REVIEW_COMMENTS = """query($owner: String!, $name: String!, $number: Int!) { |
42 | 41 | repository(owner: $owner, name: $name) { |
43 | 42 | pullRequest(number: $number) { |
44 | 43 | id |
|
66 | 65 | } |
67 | 66 | } |
68 | 67 | } |
69 | | -} |
70 | | -""" |
| 68 | +}""" |
71 | 69 |
|
72 | | -RESOLVE_REVIEW_COMMENT = """ |
73 | | -mutation($threadId: ID!) { |
| 70 | +RESOLVE_REVIEW_COMMENT = """mutation($threadId: ID!) { |
74 | 71 | resolveReviewThread(input: {threadId: $threadId, clientMutationId: "github-actions"}) { |
75 | 72 | thread { |
76 | 73 | id |
77 | 74 | } |
78 | 75 | } |
79 | | -} |
80 | | -""" |
| 76 | +}""" |
81 | 77 |
|
82 | | -DELETE_REVIEW_COMMENT = """ |
83 | | -mutation($id: ID!) { |
| 78 | +DELETE_REVIEW_COMMENT = """mutation($id: ID!) { |
84 | 79 | deletePullRequestReviewComment(input: {id: $id, clientMutationId: "github-actions"}) { |
85 | 80 | pullRequestReviewComment { |
86 | 81 | id |
87 | 82 | } |
88 | 83 | } |
89 | | -} |
90 | | -""" |
| 84 | +}""" |
91 | 85 |
|
92 | | -HIDE_REVIEW_COMMENT = """ |
93 | | -mutation($subjectId: ID!) { |
| 86 | +HIDE_REVIEW_COMMENT = """mutation($subjectId: ID!) { |
94 | 87 | minimizeComment(input: {classifier:OUTDATED, subjectId: $subjectId, clientMutationId: "github-actions"}) { |
95 | 88 | minimizedComment { |
96 | 89 | isMinimized |
97 | 90 | } |
98 | 91 | } |
99 | | -} |
100 | | -""" |
| 92 | +}""" |
101 | 93 |
|
102 | 94 |
|
103 | 95 | class GithubApiClient(RestApiClient): |
@@ -731,24 +723,12 @@ def _close_review_comment( |
731 | 723 | data=json.dumps({"query": mutation, "variables": variables}), |
732 | 724 | strict=False, |
733 | 725 | ) |
734 | | - if response.status_code != 200: |
735 | | - logger.error( |
736 | | - "Failed to %s review thread comment: %d", |
737 | | - operation, |
738 | | - response.status_code, |
739 | | - ) |
740 | | - elif "errors" in response.json(): |
741 | | - error_msg = response.json()["errors"][0]["message"] |
742 | | - if "Resource not accessible by integration" in error_msg: |
743 | | - logger.error( |
744 | | - "Changing review thread comments requires `contents: write` permission." |
745 | | - ) |
746 | | - else: |
747 | | - logger.error( |
748 | | - "Failed to %s review thread comment: %s", operation, error_msg |
749 | | - ) |
750 | | - else: |
751 | | - logger.debug("Review comment thread %sd: %s", operation, thread_id) |
| 726 | + logger.debug( |
| 727 | + "%s review comment thread %s (thread_id: %s)", |
| 728 | + operation.title(), |
| 729 | + "failed" if response.status_code != 200 else "succeeded", |
| 730 | + thread_id, |
| 731 | + ) |
752 | 732 |
|
753 | 733 | def _hide_stale_reviews(self, ignored_reviews: List[str]): |
754 | 734 | """Hide all review comments that were previously created by cpp-linter |
@@ -777,17 +757,8 @@ def _hide_stale_reviews(self, ignored_reviews: List[str]): |
777 | 757 | data=json.dumps({"query": mutation, "variables": variables}), |
778 | 758 | strict=False, |
779 | 759 | ) |
780 | | - if response.status_code != 200: |
781 | | - logger.error( |
782 | | - "Failed to hide review comment: %d", response.status_code |
783 | | - ) |
784 | | - elif "errors" in response.json(): |
785 | | - error_msg = response.json()["errors"][0]["message"] |
786 | | - if "Resource not accessible by integration" in error_msg: |
787 | | - logger.error( |
788 | | - "Hiding review comments requires `contents: write` permission." |
789 | | - ) |
790 | | - else: |
791 | | - logger.error("Hiding review comment failed: %s", error_msg) |
792 | | - else: |
793 | | - logger.debug("Review comment minimized: %s", review["node_id"]) |
| 760 | + logger.debug( |
| 761 | + "Minimized review comment: %s (node_id: %s)", |
| 762 | + repr(response.status_code != 200).lower(), |
| 763 | + review["node_id"], |
| 764 | + ) |
0 commit comments