This repository was archived by the owner on Jul 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,14 @@ class Config < CC::Service::Config
21
21
BASE_URL = "https://api.github.com"
22
22
BODY_REGEX = %r{<b>Code Climate</b> has <a href=".*">analyzed this pull request</a>}
23
23
COMMENT_BODY = '<img src="https://codeclimate.com/favicon.png" width="20" height="20" /> <b>Code Climate</b> has <a href="%s">analyzed this pull request</a>.'
24
-
25
24
# Just make sure we can access GH using the configured token. Without
26
25
# additional information (github-slug, PR number, etc) we can't test much
27
26
# else.
27
+
28
+ MESSAGES = [
29
+ DEFAULT_ERROR = "Code Climate encountered an error attempting to analyze this pull request" ,
30
+ ]
31
+
28
32
def receive_test
29
33
setup_http
30
34
@@ -87,8 +91,7 @@ def presenter
87
91
def update_status_error
88
92
update_status (
89
93
"error" ,
90
- "Code Climate encountered an error while attempting to analyze this " +
91
- "pull request."
94
+ @payload [ "message" ] || DEFAULT_ERROR
92
95
)
93
96
end
94
97
@@ -104,6 +107,9 @@ def update_status(state, description)
104
107
target_url : @payload [ "details_url" ] ,
105
108
context : "codeclimate"
106
109
}
110
+ if state == "error"
111
+ params . delete ( :target_url )
112
+ end
107
113
@response = service_post ( status_url , params . to_json )
108
114
end
109
115
end
Original file line number Diff line number Diff line change @@ -62,13 +62,28 @@ def test_pull_request_status_success_generic
62
62
def test_pull_request_status_error
63
63
expect_status_update ( "pbrisbin/foo" , "abc123" , {
64
64
"state" => "error" ,
65
- "description" => /encountered an error/ ,
65
+ "description" => CC :: Service :: GitHubPullRequests :: DEFAULT_ERROR ,
66
66
} )
67
67
68
68
receive_pull_request ( { update_status : true } , {
69
69
github_slug : "pbrisbin/foo" ,
70
70
commit_sha : "abc123" ,
71
71
state : "error" ,
72
+ message : nil ,
73
+ } )
74
+ end
75
+
76
+ def test_pull_request_status_error_message_provided
77
+ expect_status_update ( "pbrisbin/foo" , "abc123" , {
78
+ "state" => "error" ,
79
+ "description" => "descriptive message" ,
80
+ } )
81
+
82
+ receive_pull_request ( { update_status : true } , {
83
+ github_slug : "pbrisbin/foo" ,
84
+ commit_sha : "abc123" ,
85
+ state : "error" ,
86
+ message : "descriptive message" ,
72
87
} )
73
88
end
74
89
@@ -112,6 +127,7 @@ def test_no_status_update_for_error_when_update_status_config_is_falsey
112
127
github_slug : "pbrisbin/foo" ,
113
128
commit_sha : "abc123" ,
114
129
state : "error" ,
130
+ message : nil ,
115
131
} )
116
132
end
117
133
You can’t perform that action at this time.
0 commit comments