forked from RiotGamesMinions/thor-scmversion
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue RiotGamesMinions#31 - Lookup the dir hierarchy for .git dir
- 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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]> | ||
|