lib/roger/release/scm/git.rb in roger-1.6.4 vs lib/roger/release/scm/git.rb in roger-1.7.0
- old
+ new
@@ -4,10 +4,24 @@
module Roger
class Release
module Scm
# The GIT SCM implementation for Roger release
class Git < Base
+ # Find the .git dir in path and all it's parents
+ def self.find_git_dir(path)
+ path = Pathname.new(path).realpath
+ while path.parent != path && !(path + ".git").directory?
+ path = path.parent
+ end
+
+ path += ".git"
+
+ fail "Could not find suitable .git dir in #{path}" unless path.directory?
+
+ path
+ end
+
# @option config [String] :ref Ref to use for current tag
# @option config [String, Pathname] :path Path to working dir
def initialize(config = {})
super(config)
@config[:ref] ||= "HEAD"
@@ -49,11 +63,11 @@
rescue
raise "Could not get previous tag"
end
def git_dir
- @git_dir ||= find_git_dir(@config[:path])
+ @git_dir ||= self.class.find_git_dir(@config[:path])
end
# Safely escaped git dir
def safe_git_dir
Shellwords.escape(git_dir.to_s)
@@ -93,23 +107,9 @@
# Get the date in epoch time
date = `git --git-dir=#{safe_git_dir} show #{ref} --format=format:"%ct" -s 2>&1`
Time.at(date.to_i) if date =~ /\d+/
rescue RuntimeError
nil
- end
-
- # Find the git dir
- def find_git_dir(path)
- path = Pathname.new(path).realpath
- while path.parent != path && !(path + ".git").directory?
- path = path.parent
- end
-
- path += ".git"
-
- fail "Could not find suitable .git dir in #{path}" unless path.directory?
-
- path
end
end
end
end
end