Skip to content

Instantly share code, notes, and snippets.

@roelofr
Last active January 23, 2017 17:55
Show Gist options
  • Select an option

  • Save roelofr/90b6e5177053faee0a5759a689ded64a to your computer and use it in GitHub Desktop.

Select an option

Save roelofr/90b6e5177053faee0a5759a689ded64a to your computer and use it in GitHub Desktop.
Gogs or GitTea to GitHub Helper
/**!
* Quickly matches all gogs / gitea teams to the groups in your list. Adds a
* number of exlamation marks if nothing matches.
*
* @license GPL-3.0
*/
(function($) {
'use strict';
var count = 0;
var matched = 0;
$("table.import-jobs > tbody > tr").each(function() {
count += 1;
var el = $(this);
var link = el.find('a').eq(0);
if (link.length !== 1) {
return;
}
var groupName = link.text().trim().split('/')[0];
var groupSelector = el.find('select#namespace_id').eq(0);
if (groupSelector.length === 0) {
return;
}
var groups = groupSelector.find('option');
var targetGroup = groups.filter(':contains("' + groupName + '")');
if (targetGroup.length === 0) {
link.parent('td').addClass('warning');
} else {
groupSelector.val(targetGroup.attr('value'));
groupSelector.trigger('change');
matched += 1;
}
});
console.log('Found ' + count + ' item(s), ' + matched + ' could be linked.');
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment