class MDT::Fetchers::Git
A class that implements Git
fetchers
Public Class Methods
key()
click to toggle source
A method that defines a key for fetchers class. Returns:
-
“git”
# File lib/mdt/fetchers/git.rb 11 def self.key 12 'git' 13 end
subkeys()
click to toggle source
A method that defines keys for available fetchers. Returns:
-
+[“repository”]+
# File lib/mdt/fetchers/git.rb 18 def self.subkeys 19 ['repository'] 20 end
Public Instance Methods
fetch(key, options = {})
click to toggle source
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
# File lib/mdt/fetchers/git.rb 30 def fetch(key, options = {}) 31 case key 32 when 'repository' 33 return 1 unless options['url'] 34 options['branch'] ||= 'master' 35 if Dir.exist?('.git') 36 puts "Pulling changes from Git remote: origin, branch: #{options['branch']}..." 37 system("git pull origin #{options['branch']}") 38 else 39 puts "Cloning Git repository from #{options['url']}..." 40 if system("git clone #{options['url']} .") 41 puts "Checking out Git branch: #{options['branch']}..." 42 system("git checkout #{options['branch']}") 43 end 44 end 45 $?.exitstatus 46 end 47 end