Skip to content

Instantly share code, notes, and snippets.

Forked from juzna/01-choose.png
Created January 24, 2012 17:28
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fprochazka/1671348 to your computer and use it in GitHub Desktop.
GitHub Play
(function() {
var commits = [], repo = document.location.href.match(/github\.com\/([^\/]+\/[^\/]+)\//)[1];
// Play for all commits
$('.commit-group .commit-links')
.append($('<a href="#" class="browse-button github-play-select">Play</a>'));
// show next commit
var nextCommit = function () {
$('.site .container').load(commits.shift() + ' .container', function () {
$('span.sha').each(function () {
var sha = $(this).html();
$(this).replaceWith($('<a class="sha" href="/' + repo + '/commit/'+ sha + '">' + sha + '</a>'));
$('html, body').animate({scrollTop:0}, 'fast');
if (commits.length < 1) $('#next-commit').hide();
return false;
// When commit play-ed
$('.site .container').on('click', '.github-play-select', function(ev) {
$('#play-spinner').css({'left' : ev.pageX + 15, 'top' : ev.pageY + 15}).show();
var x, href = $('li.commit').find('a.gobutton')[0].href;
if(!(x = href.match(/commit\/([0-9a-f]+)/))) return false; // something must have gone wrong
var fromCommit = x[1]; //TODO: make diff from parent of this commit
$.get('' + repo + '/compare/' + fromCommit.toString() +'...HEAD', function(compare) {
$(compare).find('table.commits tr').each(function () {
commits.push($(this).find('td:first a').attr('href'));
var spinner = $('#play-spinner')
.css({'position':'relative', 'left':'0', 'top':'0'});
// next commit link
return false;
// next commit link
$('<a href="#" id="next-commit">Next commit</a>').css({
'right':'20px', 'bottom':'20px', 'position':'fixed', // position
'font-size':'20px', 'font-weight':'bold', 'display':'none', 'z-index':'1000' // style
// spinner
$('<img id="play-spinner" />')
.attr('src', GitHub.Ajax.spinner)
.css({'position':'absolute', 'display':'none', 'z-index':'1000'})
.ajaxStart(function() { $(this).show(); })
.ajaxStop(function() { $(this).hide(); });

GitHub Play

RePlay a set of commits as they happened


GitHub Play is a scriptlet, which allows you to replay commits as they happened. Usage:

  1. Go to commits history
  2. Run the play.js script (e.g. in WebInspector/FireBug or as bookmarklet)
  3. Select the commit, which you've seen as the last
  4. Hit Play on the right - it'll start Play mode and show you history between those two selected commits
  5. Hit Next commit to see the newer one


Open and run

javascript:$('head').append('<script src="" />')
Copy link

juzna commented Jan 24, 2012

Very nice!

Copy link

Feature request: link to previous commit and keyboard shortcuts (j / k?)

Copy link

Kdybych tam chtěl dávat i předchozí commit, tak se dostanu jenom na ty, které vytáhnu z toho diffu, což je divné, že. Tak jsem to tam ani nedával. Kdyby se ti chtělo, tak fork ;)

Ale klávesové zkratky jsou dobrý nápad :)

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