Class: Toolshed::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/toolshed/git.rb,
lib/toolshed/git/branch.rb,
lib/toolshed/git/github.rb,
lib/toolshed/git/validator.rb

Direct Known Subclasses

Branch, Github

Defined Under Namespace

Classes: Branch, Github, Validator

Constant Summary collapse

DEFAULT_GIT_TOOL =
'github'
DEFAULT_BRANCH_FROM =
'master'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Git

Returns a new instance of Git.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/toolshed/git.rb', line 14

def initialize(options = {})
  # options with defaults
  self.from_remote_name = Toolshed::Client.instance.pull_from_remote_name
  unless (options[:from_remote_name].nil?)
    self.from_remote_name  = options[:from_remote_name]
  end

  self.to_remote_name = Toolshed::Client.instance.push_to_remote_name
  unless (options[:to_remote_name].nil?)
    self.to_remote_name = options[:to_remote_name]
  end

  # options that do not have a default
  unless (options[:from_remote_branch_name].nil?)
    self.from_remote_branch_name = options[:from_remote_branch_name]
  end

  unless (options[:to_remote_branch_name].nil?)
    self.to_remote_branch_name = options[:to_remote_branch_name]
  end

  self.validator = ::Toolshed::Git::Validator.new
  self.passed_branch_name = options[:branch_name] || ''
  self.force = (options.key?(:force_command)) ? '--force' : ''
end

Instance Attribute Details

#forceObject

Returns the value of attribute force.



12
13
14
# File 'lib/toolshed/git.rb', line 12

def force
  @force
end

#from_remote_branch_nameObject

Returns the value of attribute from_remote_branch_name.



12
13
14
# File 'lib/toolshed/git.rb', line 12

def from_remote_branch_name
  @from_remote_branch_name
end

#from_remote_nameObject

Returns the value of attribute from_remote_name.



12
13
14
# File 'lib/toolshed/git.rb', line 12

def from_remote_name
  @from_remote_name
end

#passed_branch_nameObject

Returns the value of attribute passed_branch_name.



12
13
14
# File 'lib/toolshed/git.rb', line 12

def passed_branch_name
  @passed_branch_name
end

#to_remote_branch_nameObject

Returns the value of attribute to_remote_branch_name.



12
13
14
# File 'lib/toolshed/git.rb', line 12

def to_remote_branch_name
  @to_remote_branch_name
end

#to_remote_nameObject

Returns the value of attribute to_remote_name.



12
13
14
# File 'lib/toolshed/git.rb', line 12

def to_remote_name
  @to_remote_name
end

#validatorObject

Returns the value of attribute validator.



12
13
14
# File 'lib/toolshed/git.rb', line 12

def validator
  @validator
end

Class Method Details

.git_submodule_commandObject



41
42
43
44
45
# File 'lib/toolshed/git.rb', line 41

def git_submodule_command
  git_submodule_command = ''
  git_submodule_command = "git submodule update #{Toolshed::Client.instance.git_quiet}" if Toolshed::Client.instance.use_git_submodules
  git_submodule_command
end

Instance Method Details

#remote_updateObject



48
49
50
51
52
53
# File 'lib/toolshed/git.rb', line 48

def remote_update
  results = Toolshed::Base.wait_for_command("git remote update #{Toolshed::Client.instance.git_quiet}")
  results[:all].each do |out|
    Toolshed.logger.info out
  end
end