Skip to content

Commit

Permalink
Merge pull request #34 from RallySoftware-cookbooks/issue-31
Browse files Browse the repository at this point in the history
Issue #31 - Look up the dir hierarchy for .git dir
  • Loading branch information
capoferro committed May 29, 2014
2 parents 18e4fc9 + 56337dd commit 2bc9b38
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/thor-scmversion/scm_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@ class << self
#
# @return [#kind_of? ScmVersion]
def versioner
if(File.exist? (".git"))
if is_git?
return GitVersion
else
return P4Version
end
end

def is_git?
file_exists?(Dir.pwd, '.git')
end

def file_exists?(current_dir, file)
return true if File.exist?(file)
Dir.chdir('..') do
return false if Dir.pwd == current_dir
file_exists?(current_dir, file)
end
end
end

# author Josiah Kiehl <[email protected]>
Expand Down

0 comments on commit 2bc9b38

Please sign in to comment.