Skip to content
Browse files

support build statuses

* note that settings.json format has changed
  - renamed 'statuses' to 'review_statuses'
  - added 'build_statuses'
  • Loading branch information...
1 parent eda7ed1 commit 662150cdcf757fd9aea29666898cefd6818711d6 @jspiro jspiro committed Jan 29, 2013
Showing with 41 additions and 12 deletions.
  1. +1 −0 .gitignore
  2. +7 −1 README.md
  3. +29 −9 prviewer.coffee
  4. +4 −2 views/index.hjs
View
1 .gitignore
@@ -1,3 +1,4 @@
node_modules
npm-debug.log
settings.json
+settings-dev.json
View
8 README.md
@@ -13,6 +13,7 @@ This application provides an alternative interface to viewing pull requests on G
* Lists everyone involved in commenting in a PR
* Shows and sorts by last update time
* Shows the source branch name
+* Shows CI build status
## Getting started
@@ -33,7 +34,12 @@ This application provides an alternative interface to viewing pull requests on G
"clientSecret": "<see Applications in GitHub settings>",
"callbackURL": "<see Applications in GitHub settings>"
},
- "statuses": [
+ "buildStatuses": [
+ { "title": "Success", "class": "success", "regex": "success" },
+ { "title": "Pending", "class": "warning", "regex": "pending" },
+ { "title": "Failed", "class": "important", "regex": "fail" }
+ ],
+ "reviewStatuses": [
{ "title": "Looks good!", "class": "success", "regex": "LGTM" },
{ "title": "Please take another look", "class": "info", "regex": "PTAL" },
{ "title": "Comments", "class": "warning", "regex": "comments" }
View
38 prviewer.coffee
@@ -115,6 +115,13 @@ app.get '/', ensureAuthenticated, (req, res) ->
async.parallel [
(cb2) ->
+ github.statuses.get {
+ user: settings.github.user
+ repo: settings.github.repo
+ sha: pull.head.sha
+ }, cb2
+
+ (cb2) ->
github.pullRequests.getComments {
user: settings.github.user
repo: settings.github.repo
@@ -131,8 +138,21 @@ app.get '/', ensureAuthenticated, (req, res) ->
], (err, results) ->
return pullCb err if err
+ # Grab build status codes (if they exist).
+ statuses = results[0]
+ if statuses.length > 0
+ status = statuses[0].state
+ for config in settings.buildStatuses
+ if new RegExp(config.regex, 'i').test status
+ pull.buildStatusClass = config.class
+ pull.buildStatus = config.title
+ break
+ if not pull.buildStatus
+ pull.buildStatusClass = 'ignore'
+ pull.buildStatus = 'none'
+
# Combine issue comments and pull comments, then sort.
- comments = results[0].concat results[1]
+ comments = results[1].concat results[2]
comments.sort (a, b) -> if a.updated_at < b.updated_at then -1 else 1
# Record number of comments.
@@ -183,18 +203,18 @@ app.get '/', ensureAuthenticated, (req, res) ->
# Check for GLHF in last few comments.
if comments.length
body = comments[comments.length - 1].body
- for config in settings.statuses
+ for config in settings.reviewStatuses
if new RegExp(config.regex, 'i').test body
- pull.statusClass = config.class
- pull.status = config.title
+ pull.reviewStatusClass = config.class
+ pull.reviewStatus = config.title
break
- if not pull.status
+ if not pull.reviewStatus
if comments.length
- pull.statusClass = 'default'
- pull.status = 'Discussing'
+ pull.reviewStatusClass = 'default'
+ pull.reviewStatus = 'Discussing'
else
- pull.statusClass = 'info'
- pull.status = 'New'
+ pull.reviewStatusClass = 'info'
+ pull.reviewStatus = 'New'
# Add reviewers list to pull object.
pull.reviewers = (k for k, v of reviewers)
View
6 views/index.hjs
@@ -35,10 +35,11 @@
<th>Title</th>
<th>Submitter</th>
<th>Reviewers</th>
- <th>Status</th>
+ <th>Review Status</th>
<th>Comments</th>
<th>Last Update</th>
<th>Branch</th>
+ <th>Build Status</th>
</tr>
</thead>
@@ -53,13 +54,14 @@
<td>
{{reviewers}}
</td>
- <td><span class="label label-{{statusClass}}">{{status}}</span></td>
+ <td><span class="label label-{{reviewStatusClass}}">{{reviewStatus}}</span></td>
<td>{{num_comments}}</td>
<td class="nowrap">
{{last_update}}
{{#last_commenter}} <br/> by {{last_commenter}} {{/last_commenter}}
</td>
<td><code>{{head.ref}}</code></td>
+ <td><span class="label label-{{buildStatusClass}}">{{buildStatus}}</span></td>
</tr>
{{/pulls}}
</tbody>

0 comments on commit 662150c

Please sign in to comment.
Something went wrong with that request. Please try again.