Created
August 18, 2018 16:10
-
-
Save webknjaz/79531e72df201d5bf99cc99d2f177bb3 to your computer and use it in GitHub Desktop.
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
/* Usage: | |
* First, open https://github.com/[username]/[reponame]/network/members page of upsteam repo | |
* After that open DevTools (normally F12), and then REPL (Esc), and copy-paste this there + hit Enter | |
* Script will output a command for adding git remotes to your local repo, copy-paste that to your terminal | |
*/ | |
function get_add_forks_cmd() { | |
let main_fork_slug = prompt('Enter [username]/[reponame] slug please:') | |
let fork_slugs = $x('//*[@id="network"]/div/a[2]/@href'). | |
map(h => h.value.slice(1)) | |
let fork_map = fork_slugs. | |
map((f) => [f.slice(0, f.indexOf('/')), f]) | |
let target_forks_map = fork_map. | |
filter(([f, s]) => f != main_fork_slug) | |
let git_remote_cmds = target_forks_map. | |
map(([f, s]) => 'git remote add ' + f + ' git://github.com/' + s + '.git') | |
let git_add_forks_cmd = git_remote_cmds.join('; ') | |
return git_add_forks_cmd | |
} | |
console.log(get_add_forks_cmd()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment