Tag Archives: javascript

Filter Google Code Commits

Google code project hosting doesn’t give you an easy way to filter commits easily. In any way really. Hadeer Younis has posted a nifty script that dynamically filters them from the changes page.

Being the person I am, I refactored that script for easier usage.

  • Browse normally to the commit list page, example: http://code.google.com/p/smartsoft-12/source/list
  • Load this once:
    if(!window.jQuery||confirm('Overwrite\x20current\x20version?\x20v'+jQuery.fn.jquery))(function(d,h,s){s=d.createElement('script');s.type='text/javascript';s.src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';((h=document.head)||(h=document.getElementsByTagName('head'),h?h[0]:document.body)||document.documentElement).appendChild(s)})(document);
    var total_commits = -1;
    var results = false;
    function filter_commits(regex) {
        if (total_commits == -1) {
            total_commits = $('.pagination:first').text().split('of')[1].split('Older')[0].trim()
        }
        $('div.list b:last').html('Please wait while we filter the log...');
    	if (results == false)
    	    $('#colcontrol').load('list?num='+total_commits+' #colcontrol', function(){
    	        results = $('#resultstable>tbody').clone();
    			do_filter(regex);
    	    });
    	else
    		do_filter(regex);
    }
    function do_filter(regex) {
    	$('#resultstable>tbody').html(results.html())
    	$('#resultstable>tbody>tr + tr:visible').each(function(){
    		if(!$(this).text().match(regex))
    			$(this).hide()
    	});
    	$('div.list b:last').html('Committed changes (done filtering)');
    }
  • Run this to filter
    // enter a regular expression to match against (username, r#, [uU]pdate issue #, etc)
    filter_commits("kamasheto");