Last active
August 29, 2015 14:03
-
-
Save jkrehm/7ada41f47ca9416ccc58 to your computer and use it in GitHub Desktop.
Get commits by repository & branch from Jira
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
/*jshint browser:true, devel:true*/ | |
/*global $*/ | |
$(document).on('click', '#dvcs-commits-tabpanel', function () { | |
// Wait for the commits to load... | |
setTimeout(function () { | |
var commits = {}; | |
$('.CommitHeader > a').each(function() { | |
var $this = $(this); | |
var match = $this.attr('href').match(/https:\/\/bitbucket.org\/hp_mobile\/(cs|hcm|hpm)_web\/changeset\/(.*?)\?dvcsconnector/); | |
if (match !== null) { | |
var repo = match[1]; | |
var changeset = match[2]; | |
var branch = $this.closest('.CommiterBody').find('.CommitBodyUpTitle').text(); | |
if (typeof commits[repo] === 'undefined') { | |
commits[repo] = {}; | |
} | |
if (typeof commits[repo][branch] === 'undefined') { | |
commits[repo][branch] = []; | |
} | |
commits[repo][branch].push(changeset); | |
} | |
}); | |
console.clear(); | |
if (Object.keys(commits).length === 1) { | |
var repo = Object.keys(commits)[0]; | |
console.log(repo); | |
if (Object.keys(commits[repo]).length === 1) { | |
var branch = Object.keys(commits[repo])[0]; | |
console.log(branch); | |
console.log(commits[repo][branch]); | |
} else { | |
console.log(commits[repo]); | |
} | |
} else { | |
console.log(commits); | |
} | |
}, 2000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment