Module: PullEverything

Defined in:
lib/pull_everything.rb,
lib/pull_everything/version.rb

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.create_pr(repo, username) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/pull_everything.rb', line 31

def self.create_pr(repo, username)
  begin
    Octokit.create_pull_request(repo, "master", "#{username}:master", "#{username}'s Solution'")
  rescue Octokit::UnprocessableEntity
    puts "#{repo}: PR already exists."
    return
  end
  puts "#{repo}: Created PR!"
end

.runObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pull_everything.rb', line 5

def self.run
  puts "Let's make Pull Requests for All The Things!"
  puts "----------"

  puts "What's your GitHub username?"
  username = gets.chomp
  puts "What's your GitHub password?"
  password = gets.chomp

  Octokit.configure do |c|
    c. = username
    c.password = password
  end

  Octokit.auto_paginate = true
  forks = Octokit.repos(nil, type: 'owner')
  forks.each do |fork|
    next unless fork.fork && fork.owner. == username
    repo = Octokit.repo(fork.full_name)
    sleep 1
    next unless repo&.parent&.owner&. == 'vikingeducation'
    parent = repo.parent.full_name
    create_pr(parent, username)
  end
end