Skip to content

Instantly share code, notes, and snippets.

@codebycliff
Forked from zach-taylor/Rakefile
Created January 27, 2017 17:07

Revisions

  1. @zach-taylor zach-taylor created this gist Oct 29, 2016.
    31 changes: 31 additions & 0 deletions Rakefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    # gem install bitbucket_rest_api
    # gem install octokit
    require 'bitbucket_rest_api'
    require 'octokit'

    task :migrate do
    bitbucket = BitBucket.new login: '', password: ''
    bitbucket_owner = ''
    github = Octokit::Client.new login: '', password: ''
    github_org = ''


    bitbucket.repos.list do |repo|
    next unless repo.owner == bitbucket_owner


    if github.repository?("#{github_org}/#{repo.slug}")
    puts "#{repo.slug} exists! ================================="
    else
    github.create_repo(repo.slug, organization: github_org, private: true)
    url = "https://bitbucket.org/#{repo.owner}/#{repo.slug}"
    system("mkdir #{repo.slug}")
    system("git clone --mirror #{url} #{repo.slug}/.git")
    Dir.chdir(repo.slug) do
    system("git config --bool core.bare false")
    system("git remote add gh https://github.com/#{github_org}/#{repo.slug}")
    system("git push --all gh")
    end
    end
    end
    end