Sha256: 7649feedb5308929e066ecf423e6bbdd342f6392dfc17a2aa3f1ab4400f4b435

Contents?: true

Size: 723 Bytes

Versions: 4

Compression:

Stored size: 723 Bytes

Contents

require 'contracts'
require 'octokit'
require 'progress_bar'
require_relative 'settings'

module GitHub
  include Contracts

  Contract String => ArrayOf[({ upstream: Sawyer::Resource, origin: Sawyer::Resource })]
  def self.fork_all(organization)
    repositories = %w(public, private).flat_map do |type|
      api.org_repos(organization, type: type)
    end
    progress = ProgressBar.new repositories.length
    repositories.flat_map do |repository|
      progress.increment!
      { upstream: repository, origin: api.fork(repository[:full_name]) }
    end
  end

  Contract nil => Octokit::Client
  def self.api
    @api ||= Octokit::Client.new access_token: Settings.github_access_token, auto_paginate: true
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
git-ready-0.8.10 lib/git-ready/github.rb
git-ready-0.8.9 lib/git-ready/github.rb
git-ready-0.8.8 lib/git-ready/github.rb
git-ready-0.8.7 lib/git-ready/github.rb