Class: GitShallowClone
- Inherits:
-
Object
- Object
- GitShallowClone
- Defined in:
- lib/gitarro/git_op.rb
Overview
handle shallow clone by default
Instance Attribute Summary collapse
-
#git_dir ⇒ Object
readonly
Returns the value of attribute git_dir.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#pr ⇒ Object
readonly
Returns the value of attribute pr.
-
#repo_protocol ⇒ Object
readonly
Returns the value of attribute repo_protocol.
Instance Method Summary collapse
-
#clone ⇒ Object
shallow clone.
-
#initialize(git_dir, pr, options) ⇒ GitShallowClone
constructor
A new instance of GitShallowClone.
Constructor Details
#initialize(git_dir, pr, options) ⇒ GitShallowClone
Returns a new instance of GitShallowClone.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gitarro/git_op.rb', line 11 def initialize(git_dir, pr, ) @git_dir = git_dir # pr object for extract all relev. data. @pr = pr # All gitarro options @options = gh = 'https://github.com/' gg = '[email protected]:' @repo_protocol = @options[:https] ? gh : gg @repo_url = @options[:https] ? pr.head.repo.html_url : pr.head.repo.ssh_url end |
Instance Attribute Details
#git_dir ⇒ Object (readonly)
Returns the value of attribute git_dir.
10 11 12 |
# File 'lib/gitarro/git_op.rb', line 10 def git_dir @git_dir end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/gitarro/git_op.rb', line 10 def @options end |
#pr ⇒ Object (readonly)
Returns the value of attribute pr.
10 11 12 |
# File 'lib/gitarro/git_op.rb', line 10 def pr @pr end |
#repo_protocol ⇒ Object (readonly)
Returns the value of attribute repo_protocol.
10 11 12 |
# File 'lib/gitarro/git_op.rb', line 10 def repo_protocol @repo_protocol end |
Instance Method Details
#clone ⇒ Object
shallow clone
24 25 26 27 28 29 30 |
# File 'lib/gitarro/git_op.rb', line 24 def clone tmp_dir = create_tmp_dir! git_local = "#{git_dir}/#{tmp_dir}" puts `git clone --depth 1 #{@repo_url} -b #{pr.head.ref} #{git_local}` exit 1 if $CHILD_STATUS.exitstatus.nonzero? Dir.chdir git_local end |