Sha256: 25b9a765aee33d3f731ea1d53d11acb1c657d3eb0f4ab41e1924f9a9375c4341

Contents?: true

Size: 735 Bytes

Versions: 2

Compression:

Stored size: 735 Bytes

Contents

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

module GitHub
  include Contracts

  Contract String, String => ArrayOf[({ upstream: Sawyer::Resource, origin: Sawyer::Resource })]
  def self.fork_all(organization, filter=nil)
    repositories = api.org_repos(organization).select { |repository| repository.name.include? filter }
    progress = ProgressBar.new repositories.length
    repositories.flat_map do |repository|
      progress.increment!
      { upstream: repository, origin: api.fork(repository[:full_name]) }
    end
  end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git-ready-0.9.8 lib/git-ready/github.rb
git-ready-0.9.0 lib/git-ready/github.rb