Last active
October 30, 2017 19:42
-
-
Save starlocke/a617f32e5ca23f0a4c6a to your computer and use it in GitHub Desktop.
Print out all "git remote add" commands for all the forks of a project.
This file contains hidden or 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
// Execute this function upon a project's "/network/members" page. | |
// - You also need to "inject" jQuery onto that page, first. | |
// Ex: https://github.com/example/test/network/members (replace "example/test" - NO LONGER WORKS) | |
// Ex: https://github.com/google/git-appraise-web/network/members (another example) | |
function add_all_github_forks(){ | |
var matches = window.location.href.match(/github.com[/]\w+[/]([^/]+)/); // [^/]+ used to be \w+, now also captures "-" in names | |
var project_name = ''; | |
if(matches == null){ | |
console.log("no match, quitting early"); | |
return; | |
} | |
else { | |
project_name = matches[1]; | |
} | |
console.log("project name: " + project_name); | |
$('#network a[href$="\/'+project_name+'"]:contains("'+project_name+'"):gt(1)').each(function(){ | |
var href = $(this).attr('href'); | |
var remote = "https://github.com" + href + ".git"; | |
var expr = new RegExp('[/]([^/]*)[/]'+project_name) | |
var match = href.match(expr); | |
var fork = match[1]; | |
console.log("git remote add " + fork + " " + remote) | |
}); | |
} | |
add_all_github_forks(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment