5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/ruby_maat/vcs_detector.rb', line 5
def self.detect_vcs(path = ".")
expanded_path = File.expand_path(path)
git_dir = File.join(expanded_path, ".git")
if Dir.exist?(git_dir) || File.exist?(git_dir)
return "git"
end
svn_dir = File.join(expanded_path, ".svn")
if Dir.exist?(svn_dir)
return "svn"
end
hg_dir = File.join(expanded_path, ".hg")
if Dir.exist?(hg_dir)
return "hg"
end
p4config = File.join(expanded_path, ".p4config")
if File.exist?(p4config)
return "p4"
end
begin
Dir.chdir(expanded_path) do
`git status 2>/dev/null`
return "git" if $?.exitstatus == 0
`svn info 2>/dev/null`
return "svn" if $?.exitstatus == 0
`hg status 2>/dev/null`
return "hg" if $?.exitstatus == 0
`p4 info 2>/dev/null`
return "p4" if $?.exitstatus == 0
end
rescue
end
nil
end
|