Class: GitOp
- Inherits:
-
Object
- Object
- GitOp
- Defined in:
- lib/gitarro/git_op.rb
Overview
This class is used by lib/backend.rb git operation for gitarro
Instance Attribute Summary collapse
-
#git_dir ⇒ Object
readonly
Returns the value of attribute git_dir.
-
#pr ⇒ Object
readonly
Returns the value of attribute pr.
-
#pr_fix ⇒ Object
readonly
Returns the value of attribute pr_fix.
-
#repo_external ⇒ Object
readonly
Returns the value of attribute repo_external.
-
#repo_protocol ⇒ Object
readonly
Returns the value of attribute repo_protocol.
Instance Method Summary collapse
-
#del_pr_branch(upstream, pr) ⇒ Object
cleanup the pr_branch(delete it).
-
#initialize(git_dir, pr, options) ⇒ GitOp
constructor
A new instance of GitOp.
-
#merge_pr_totarget(upstream, pr_branch) ⇒ Object
merge pr_branch into upstream targeted branch.
Constructor Details
#initialize(git_dir, pr, options) ⇒ GitOp
Returns a new instance of GitOp.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gitarro/git_op.rb', line 44 def initialize(git_dir, pr, ) @git_dir = git_dir # prefix for the test pr that gitarro tests. @pr_fix = 'PR-' # pr object for extract all relev. data. @pr = pr # All gitarro options @options = # object to handle external repos @repo_external = ExternalRepoGit.new(pr, ) gh = 'https://github.com/' gg = '[email protected]:' @repo_protocol = @options[:https] ? gh : gg end |
Instance Attribute Details
#git_dir ⇒ Object (readonly)
Returns the value of attribute git_dir.
43 44 45 |
# File 'lib/gitarro/git_op.rb', line 43 def git_dir @git_dir end |
#pr ⇒ Object (readonly)
Returns the value of attribute pr.
43 44 45 |
# File 'lib/gitarro/git_op.rb', line 43 def pr @pr end |
#pr_fix ⇒ Object (readonly)
Returns the value of attribute pr_fix.
43 44 45 |
# File 'lib/gitarro/git_op.rb', line 43 def pr_fix @pr_fix end |
#repo_external ⇒ Object (readonly)
Returns the value of attribute repo_external.
43 44 45 |
# File 'lib/gitarro/git_op.rb', line 43 def repo_external @repo_external end |
#repo_protocol ⇒ Object (readonly)
Returns the value of attribute repo_protocol.
43 44 45 |
# File 'lib/gitarro/git_op.rb', line 43 def repo_protocol @repo_protocol end |
Instance Method Details
#del_pr_branch(upstream, pr) ⇒ Object
cleanup the pr_branch(delete it)
76 77 78 79 |
# File 'lib/gitarro/git_op.rb', line 76 def del_pr_branch(upstream, pr) `git checkout #{upstream}` `git branch -D #{pr_fix}#{pr}` end |
#merge_pr_totarget(upstream, pr_branch) ⇒ Object
merge pr_branch into upstream targeted branch
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/gitarro/git_op.rb', line 60 def merge_pr_totarget(upstream, pr_branch) goto_prj_dir check_git_dir `git checkout #{upstream}` check_duplicata_pr_branch("#{pr_fix}#{pr_branch}") `git remote update` `git fetch` `git pull origin #{upstream}` `git checkout -b #{pr_fix}#{pr_branch} origin/#{pr_branch}` return if $CHILD_STATUS.exitstatus.zero? # if it fails the PR contain a forked external repo repo_external.checkout_into end |