Created
February 2, 2013 19:53
-
-
Save joshuaflanagan/4699004 to your computer and use it in GitHub Desktop.
UserScript to show Labels on Pull Requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Pull Request Labels | |
// @namespace http://joshuaflanagan.com | |
// @include https://github.com/*/*/pulls | |
// @version 1 | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js | |
// ==/UserScript== | |
$(function(){ | |
var $pull_requests = $(".pulls-list .list-browser-item h3"); | |
$pull_requests.each(function(){ | |
var pull_request = this; | |
$(pull_request).addClass("issues-list"); // styling | |
var $link = $("a:first", pull_request); | |
var href = $link.attr("href"); | |
//ex: /user/repo/pulls/42 | |
var href_parts = href.split('/'); | |
href_parts[3] = "issues"; | |
var issue_href = href_parts.join('/'); | |
$.getJSON("https://api.github.com/repos" + issue_href, function(issue){ | |
$.each(issue.labels, function(l_i, label){ | |
// <span data-name="actionpack" class="label labelstyle-FFF700">actionpack</span> | |
var new_elem = $('<span class="label">' + label.name + '</span>'). | |
css("background", '#' + label.color); | |
$(pull_request).append(new_elem); | |
}); | |
}); | |
}); | |
}); |
What about an intermediate service that coughs those up?
A little Heroku app to auth the request then forward it through with the private credentials?
@joshuaflanagan to make it work with private repo, create an access token in your account setting and add it in the query string as access_token
. It obviously requires modifying the user script when installing it as you don't want to put an access token in the gist (and you cannot provide a way to configure it externally AFAIK)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a quick and dirty attempt at solving my own problem:
https://twitter.com/jflanagan/status/297745577444253696
Unfortunately, it doesn't work with private repos. Not sure if there is any simple way to make authenticated GitHub API calls within a userscript. Might be better off changing it to load the Issue HTML pages and parsing them for the labels.