Class: Gub::Git
- Inherits:
-
Object
show all
- Defined in:
- lib/gub/clients/git.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
21
22
23
|
# File 'lib/gub/clients/git.rb', line 21
def method_missing meth, *args, &block
self.run(meth, *args)
end
|
Instance Attribute Details
#default_options ⇒ Object
Returns the value of attribute default_options.
3
4
5
|
# File 'lib/gub/clients/git.rb', line 3
def default_options
@default_options
end
|
Instance Method Details
#clone(repo, *args) ⇒ Object
Due to clone being a Ruby magic method, we have to override it
17
18
19
|
# File 'lib/gub/clients/git.rb', line 17
def clone repo, *args
self.run('clone', repo, *args)
end
|
#remotes ⇒ Object
12
13
14
|
# File 'lib/gub/clients/git.rb', line 12
def remotes
`git remote -v | grep fetch | awk '{print $2}' | cut -d ':' -f 2`.split("\n").split(' ').map(&:chop)
end
|
#run(command, *args) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/gub/clients/git.rb', line 26
def run command, *args
command = command.to_s
default_options = []
default_options << '-q'
cmd = []
cmd << 'git'
cmd << command
arguments = args
unless ['clone', 'remote', 'checkout'].include?(command)
arguments = arguments.zip(default_options).flatten!
end
cmd << arguments.join(' ').to_s
cmd_line = cmd.join(' ')
Gub.log.debug "Running git command: #{cmd_line}"
`#{cmd_line}`
end
|
#sync ⇒ Object
5
6
7
8
9
10
|
# File 'lib/gub/clients/git.rb', line 5
def sync
self.checkout('master')
self.fetch('upstream')
self.merge('upstream/master')
self.push('origin', '--all')
end
|