Skip to content

Instantly share code, notes, and snippets.

@agnoster
Created October 17, 2012 15:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save agnoster/3906361 to your computer and use it in GitHub Desktop.
Save agnoster/3906361 to your computer and use it in GitHub Desktop.
Like editing files in an open pull request?
/**
* 1) Use http://defunkt.io/dotjs/
* 2) Install this into ~/.js/github.com.js
* 3) Enjoy a button to edit any file on a pull request (some restrictions may apply, void where prohibited)
*
* Note: this will replace the "View file @ ...", which I find pretty useless (and it's contained in the edit mode,
* anyway). However, if you want to look at files where you don't have access to edit them, this will suck.
*/
function getBranch() {
return $($('.pull-description .commit-ref')[1]).text().trim()
}
function updateButtons() {
var branch = getBranch()
if (!branch) return // couldn't get a branch? NOT A PULL REQUEST
$('.actions .minibutton').each(function(i, el) {
el = $(el)
el.attr('href', el.attr('href').replace(/blob\/[a-z0-9]+/, 'edit/' + branch))
el.html('Edit file @ <code>' + branch + '</code>')
})
}
$(function() {
updateButtons()
})
@daniel-marschner
Copy link

Works like a charm -- good job!

@larsxschneider
Copy link

Great stuff!

@arsduo
Copy link

arsduo commented Nov 5, 2012

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment