// ==UserScript== // @name TFS Changeset History Helper // @namespace http://jonas.ninja // @version 1.2.0 // @description Changeset reference utilities // @author @_jnblog // @match http://*/tfs/DefaultCollection/*/_versionControl* // @require https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js // @grant GM_addStyle // @downloadURL none // ==/UserScript== /* jshint -W097 */ /* global $ */ /* jshint asi: true, multistr: true */ 'use strict'; waitForKeyElements('.history-result', doEverything, false) waitForKeyElements(".vc-page-title[title^=Changeset]", addChangesetIdCopyUtilities, true) $(document).on('mouseenter', '.history-result, .ijg-changeset-id', highlightHistoryResult) .on('mouseleave', '.history-result, .ijg-changeset-id', unhighlightHistoryResult) $(document).on('click', 'input.ijg-copy-changeset-id', function clickToCopy(e) { var historyResult = $(this).closest('.history-result') var mergedChangesetRegex = / \(merge c\d{5,} to QA\)/gi if (e.ctrlKey) { // if CTRL is held down, copy first the task ID, then a commit message. Only useful if you have a clipboard manager like Ditto. var taskId = historyResult.data('ijgTaskId') var that = this copy(this, $(this).next('span.ijg-copy-message'), taskId) var optMessage = historyResult.find('.change-link').text() if (optMessage.match(mergedChangesetRegex)) { // a changeset that's already merged to QA should merge to Release optMessage = optMessage.replace(mergedChangesetRegex, ' (merge c' + that.value + ' to Release)') } else { optMessage = optMessage.replace(/(^t\d{5,})/, '$1 (merge c' + that.value + ' to QA)') // optMessage += ' (merge c' + that.value + ' to QA)' } window.setTimeout(function() { copy(that, $(that).next('span.ijg-copy-message'), optMessage) }, 250) } else { copy(this, $(this).next('span.ijg-copy-message')) } }) $(document).on('click', 'input.ijg-copy-changeset-page-link', function clickToCopy(e) { // if shift is held down, copy a commit message var optMessage if (e.ctrlKey) { optMessage = $('.vc-change-summary-comment').text() + ' (merge c' + this.value + ' to QA)' } copy(this, $(this).next('span.ijg-copy-message'), optMessage) }) function doEverything(historyResult) { historyResult = $(historyResult) spanifyText(historyResult) addCopyUtilities(historyResult) createTaskContainers(historyResult) //fetchTaskLinks(historyResult) } function createTaskContainers(historyResult) { // makes a positioned div in the right place to hold Task info var tasks = historyResult.find('.ijg-task-id') if (tasks.size()) { // make a container and append rows var container = $('
') historyResult.find('.change-link-container').append(container) tasks.each(function() { var tasknum = $(this).data('ijgTaskId') var task = $('