Skip to content

Commit

Permalink
Issue RiotGamesMinions#31 - Lookup the dir hierarchy for .git dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Chauncey and Russ Teabeault committed Feb 24, 2014
1 parent 18e4fc9 commit 56337dd
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 56337dd

Please sign in to comment.