Skip to content

Instantly share code, notes, and snippets.

@webknjaz
Created August 18, 2018 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webknjaz/79531e72df201d5bf99cc99d2f177bb3 to your computer and use it in GitHub Desktop.
Save webknjaz/79531e72df201d5bf99cc99d2f177bb3 to your computer and use it in GitHub Desktop.
/* 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