class MGMT::Dep
Attributes
name[R]
repo[R]
rev[RW]
tag[RW]
Public Class Methods
new(name, opts = {})
click to toggle source
# File bin/mgmt, line 143 def initialize(name, opts = {}) @name = name @tag = opts[:tag] # Specified tag @rev = opts[:rev] # Locked rev @repo = opts[:repo] || "http://#{name}" end
parse(line, field)
click to toggle source
# File bin/mgmt, line 121 def self.parse(line, field) line = line.strip return if line[0] == "#" tokens = line.split(/ +/) return if tokens.empty? opts = {} tokens[1..-1].each do |token| case token[0] when "!", 33 opts[:repo] = token[1..-1] when "#", 35 opts[field] = token[1..-1] end end new tokens[0], opts end
Public Instance Methods
pull!()
click to toggle source
# File bin/mgmt, line 158 def pull! current = MGMT.shv("cd #{target} && git --git-dir=.git log -n 1 --pretty=format:'%h'") if File.directory?(target) return false if current && current == rev if current.nil? MGMT.sh "git clone -q #{@repo} #{target}" else MGMT.sh "cd #{target} && git --git-dir=.git fetch -q origin" end remote = "origin/#{version}" @rev = MGMT.shv "cd #{target} && git --git-dir=.git show-ref -q #{remote} && git --git-dir=.git rev-parse --short #{remote} || git --git-dir=.git rev-parse --short #{version}" MGMT.sh "cd #{target} && git --git-dir=.git reset -q --hard #{rev}" true end
target()
click to toggle source
# File bin/mgmt, line 150 def target @target ||= File.join(VENDOR, 'src', @name) end
to_s()
click to toggle source
# File bin/mgmt, line 175 def to_s "#{@name} ##{version} !#{@repo}" end
version()
click to toggle source
# File bin/mgmt, line 154 def version @rev || @tag || 'master' end