class ExternalRepoGit
This private class handle the case the repo from PR comes from a user external repo PR open against: openSUSE/gitarro PR repo: MyUSER/gitarro
Attributes
pr[R]
pr_fix[R]
rem_repo[R]
Public Class Methods
new(pr, options)
click to toggle source
# File lib/gitarro/git_op.rb, line 132 def initialize(pr, options) # pr object for extract all relev. data. @pr = pr @pr_fix = 'PR-' @options = options end
Public Instance Methods
checkout_into()
click to toggle source
# File lib/gitarro/git_op.rb, line 139 def checkout_into rem_repo = 'rem' + pr.head.ref add_remote(rem_repo) fetch_remote(rem_repo) checkout_to_rem_branch(rem_repo) remove_repo(rem_repo) end
Private Instance Methods
add_remote(rem_repo)
click to toggle source
# File lib/gitarro/git_op.rb, line 158 def add_remote(rem_repo) repo_url = @options[:https] ? pr.head.repo.html_url : pr.head.repo.ssh_url puts `git remote add #{rem_repo} #{repo_url}` end
branch_rem()
click to toggle source
# File lib/gitarro/git_op.rb, line 154 def branch_rem pr.head.ref end
checkout_to_rem_branch(rem_repo)
click to toggle source
# File lib/gitarro/git_op.rb, line 149 def checkout_to_rem_branch(rem_repo) puts `git checkout -b #{pr_fix}#{branch_rem} #{rem_repo}/#{branch_rem}` exit 1 if $CHILD_STATUS.exitstatus.nonzero? end
fetch_remote(rem_repo)
click to toggle source
# File lib/gitarro/git_op.rb, line 163 def fetch_remote(rem_repo) puts `git remote update` puts `git fetch` puts `git pull #{rem_repo} #{pr.head.ref}` end
remove_repo(rem_repo)
click to toggle source
# File lib/gitarro/git_op.rb, line 169 def remove_repo(rem_repo) puts `git remote remove #{rem_repo}` end