-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'head_branch' to GitHubChecksRerunActionCause #223 #226
Conversation
Codecov Report
@@ Coverage Diff @@
## master #226 +/- ##
============================================
+ Coverage 79.65% 79.88% +0.23%
Complexity 168 168
============================================
Files 16 16
Lines 516 522 +6
Branches 47 47
============================================
+ Hits 411 417 +6
Misses 83 83
Partials 22 22
Continue to review full report at Codecov.
|
I think ok but can you sort checkstyle issues, yes the config is weird here… |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. The PMD warning will automatically be fixed if you combine the try
blocks.
LOGGER.log(Level.INFO, "Received rerun request through GitHub checks API."); | ||
try (ACLContext ignored = ACL.as(ACL.SYSTEM)) { | ||
scheduleRerun(checkRun); | ||
scheduleRerun(checkRun, branchName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual code that does something useful would be simpler to find if you would use one try-catch block for the whole method (calls in line 73 and 86), then you can integrate the variable assignments in the declaration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the first part of the code in #227.
conflicted now |
thanks for quick response - i should have some time tomorrow to update this to both fix the conflict and to take the excellent recommendation of uhafner |
try { | ||
GHEventPayload.CheckRun checkRun = GitHub.offline().parseEventPayload(new StringReader(payload), GHEventPayload.CheckRun.class); | ||
|
||
JSONObject payloadJSON = new JSONObject(payload); | ||
branchName = payloadJSON.getJSONObject("check_run").getJSONObject("check_suite").getString("head_branch"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the head_branch
can be null:
jenkins-infra/helpdesk#2738 (comment)
https://docs.github.com/en/rest/reference/checks#suites
Note: The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array and a null value for head_branch.
it's null for forks
Pull the 'head_branch' name out from the check_runs check_suite head_branch property, add it to the build cause along side an accessor for it.
Issue: #223