lib/docman/git_util.rb in docman-0.0.80 vs lib/docman/git_util.rb in docman-0.0.81
- old
+ new
@@ -6,11 +6,11 @@
@logger = Logger.new(STDOUT)
@git = ENV.has_key?('GIT_CMD') ? ENV['GIT_CMD'] : 'git'
def self.exec(command, show_result = true)
- @logger.info "#{@git} #{command}"
+ @logger.info "#{@git} #{command} in #{Dir.pwd}"
result = `#{@git} #{command}`
#result = `#{@git} #{command}`.delete!("\n")
@logger.info result if show_result and result
raise "ERROR: #{result}" unless $?.exitstatus == 0
result
@@ -31,17 +31,17 @@
def self.get(repo, path, type, version, single_branch = nil, depth = nil, reset = false)
FileUtils.rm_rf path if reset and File.directory? path
if File.directory? path and File.directory?(File.join(path, '.git'))
Dir.chdir path
self.reset_repo(path) #if self.repo_changed?(path)
+ exec 'fetch --tags'
if type == 'branch'
- exec "fetch"
+ #exec "fetch"
exec "checkout #{version}"
exec "pull origin #{version}"
end
if type == 'tag'
- exec 'fetch --tags'
exec "checkout tags/#{version}"
end
else
FileUtils.rm_rf path if File.directory? path
clone_repo(repo, path, type, version, single_branch, depth)
@@ -61,14 +61,14 @@
depth=''
end
exec("clone #{single_branch} #{depth} #{repo} #{path}")
end
- def self.last_revision(path = nil)
+ def self.last_revision(path = nil, branch = 'HEAD')
result = nil
if self.repo? path
Dir.chdir path unless path.nil?
- result = `git rev-parse --short HEAD`
+ result = `git rev-parse --short #{branch}`
result.delete!("\n")
end
result
end
\ No newline at end of file