Created
May 24, 2016 07:47
-
-
Save oriolgual/a5ac8139120d06b51b16b902c324d530 to your computer and use it in GitHub Desktop.
Script to mass move repositories from a GitHub user to another
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
source "https://www.rubygems.org" | |
ruby '2.2.4' | |
gem 'byebug' | |
gem 'capybara' | |
gem 'selenium-webdriver' |
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
# Require the gems | |
# run with ruby move_repos.rb | |
require 'rubygems' | |
require 'bundler/setup' | |
require 'capybara' | |
Capybara.current_driver = :selenium | |
Capybara.app_host = 'https://www.github.com' | |
Capybara.run_server = false | |
session = Capybara::Session.new(:selenium) | |
session.visit('/') | |
session.click_link('Sign in') | |
session.fill_in('Username', with: 'YOUR_USERNAME') | |
session.fill_in('Password', with: 'YOUR_PASSWORD') | |
session.click_button('Sign in') | |
repos = %w(repo1 repo2) | |
repos.each do |repo| | |
session.visit("https://github.com/YOUR_USERNAME/#{repo}/settings") | |
session.click_button('Transfer') | |
session.fill_in('Type the name of the repository to confirm', with: repo) | |
session.fill_in('New owner’s GitHub username or organization name', with: 'TARGET_USER') | |
session.click_button('I understand, transfer this repository.') | |
session.find('label', text: 'TEAM_NAME').click | |
session.click_button('Transfer') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment