Skip to content

Instantly share code, notes, and snippets.

@Potherca
Last active December 5, 2016 11:50
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 Potherca/f4ad083c710acd19026d to your computer and use it in GitHub Desktop.
Save Potherca/f4ad083c710acd19026d to your computer and use it in GitHub Desktop.
Bookmarklet to transfer ownership of a Github repository from "foo" to "foo-contrib"

Lights...

On github, I have a lot of repositories. I wanted to have a clear distinction between original projects and contributions.

Then I had an idea.

Why not move all repositories that are forks to a separate "contrib" company account.?

Camera...

The Github transfer process takes several clicks and two text fields to fill in. For dozens of repositories, this is a lot of tedious work, so I decided to see if I could automate it

Action!

There does not seem to be a call to transfer ownership in the Github API. Or there is and I'm too lazy to find it. So I went another route...

I created a bookmarklet that does all the work. I opened all the repository pages and clicked the bookmarklet.

It's a wrap

I'm sure I could automate things even further. For instance, the pages don't have to be opened by hand.

For now, this worked well enough for me.

var sRepo = $('#rename_field').val()
, sName = $('[itemprop=title]').text() + '-contrib';
/* Open "Transfer Ownership" modal dialog */
$('#transfer_button').trigger('click');
/* Set input values */
$('#confirm_repository_name').val(sRepo);
$('#confirm_new_owner').val(sName);
/* Submit the form */
$('[action*=transfer] button[type=submit]').removeAttr('disabled').trigger('click');
`
/*EOF*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment