class GithubTV::Sync

Public Class Methods

new(client, target, source_repo) click to toggle source
# File lib/github-tv.rb, line 31
def initialize(client, target, source_repo)
  @client = client
  @target = target
  @source, @project = source_repo.split('/')
end

Public Instance Methods

run() click to toggle source
# File lib/github-tv.rb, line 37
def run
  if @client.repository? target_repo
    fast_forward
    puts "#@project fast-forwarded"
  else
    @client.fork source_repo, organization: @target
    puts "#@project forked"
  end
end

Private Instance Methods

fast_forward() click to toggle source
# File lib/github-tv.rb, line 49
    def fast_forward
      system <<-SH
        [ -d #@project.git ] || git clone --mirror #{source_url}
        cd #@project.git
        git fetch -p origin
        git push --mirror #{target_url}
      SH
    end
source_repo() click to toggle source
# File lib/github-tv.rb, line 62
def source_repo
  "#@source/#@project"
end
source_url() click to toggle source
# File lib/github-tv.rb, line 66
def source_url
  "https://github.com/#{source_repo}.git"
end
target_repo() click to toggle source
# File lib/github-tv.rb, line 58
def target_repo
  "#@target/#@project"
end
target_url() click to toggle source
# File lib/github-tv.rb, line 70
def target_url
  "https://#{@client.access_token}@github.com/#{target_repo}.git"
end