Created
October 9, 2013 06:05
-
-
Save m6w6/6896890 to your computer and use it in GitHub Desktop.
github pull merge status
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
var parts=window.location.pathname.split('/'); | |
if(parts[3] == 'pull') { | |
var url='https://api.github.com/repos/'+parts[1]+'/'+parts[2]+'/pulls/'+parts[4]; | |
var xhr = new XMLHttpRequest; | |
xhr.onload = function() { | |
switch (xhr.status) { | |
case 200: | |
case 304: | |
break; | |
default: | |
return; | |
} | |
var pullinfo = JSON.parse(xhr.responseText); | |
var statsdiv = document.querySelectorAll('#discussion_bucket .discussion-sidebar .discussion-stats').item(0); | |
if (!pullinfo.merged) { | |
var p = document.createElement("SPAN"); | |
if (pullinfo.mergeable) { | |
p.className = "state-indicator open"; | |
p.innerHTML = "mergeable"; | |
var r = document.createElement("INPUT"); | |
r.onfocus = function(e) { | |
r.select(); | |
e.preventDefault(); | |
}; | |
r.type = "text"; | |
r.readonly = true; | |
r.style.fontSize = "8px"; | |
r.style.width = "80px"; | |
r.style.padding = "2px"; | |
r.value = pullinfo.head.repo.clone_url + " " + pullinfo.head.ref; | |
p.appendChild(document.createElement("BR")); | |
p.appendChild(r); | |
} else { | |
p.className = "state-indicator closed"; | |
p.innerHTML = "can't merge"; | |
} | |
statsdiv.appendChild(p); | |
} | |
// console.log(pullinfo); | |
}; | |
xhr.open("GET", url, true); | |
xhr.send(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment