Class: MDT::Fetchers::Git
- Inherits:
-
Base
- Object
- Base
- MDT::Fetchers::Git
- Defined in:
- lib/mdt/fetchers/git.rb
Overview
A class that implements Git fetchers
Class Method Summary collapse
-
.key ⇒ Object
A method that defines a key for fetchers class.
-
.subkeys ⇒ Object
A method that defines keys for available fetchers.
Instance Method Summary collapse
-
#fetch(key, options = {}) ⇒ Object
A method that defines how to fetch project contents to a deploy directory with fetchers.
Class Method Details
.key ⇒ Object
A method that defines a key for fetchers class. Returns:
-
“git”
11 12 13 |
# File 'lib/mdt/fetchers/git.rb', line 11 def self.key 'git' end |
.subkeys ⇒ Object
A method that defines keys for available fetchers. Returns:
-
[“repository”]
18 19 20 |
# File 'lib/mdt/fetchers/git.rb', line 18 def self.subkeys ['repository'] end |
Instance Method Details
#fetch(key, options = {}) ⇒ Object
A method that defines how to fetch project contents to a deploy directory with fetchers. Arguments:
-
key- a key identifier of a particular fetcher -
options- options for fetchers as a Hash
Returns:
-
Exit code for fetcher
key
More information:
-
See README.md for detailed description of fetchers
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mdt/fetchers/git.rb', line 30 def fetch(key, = {}) case key when 'repository' return 1 unless ['url'] ['branch'] ||= 'master' if Dir.exist?('.git') puts "Pulling changes from Git remote: origin, branch: #{['branch']}..." system("git pull origin #{['branch']}") else puts "Cloning Git repository from #{['url']}..." if system("git clone #{['url']} .") puts "Checking out Git branch: #{['branch']}..." system("git checkout #{['branch']}") end end $?.exitstatus end end |