Module: VCDetect
- Defined in:
- lib/version.rb,
lib/vcdetect.rb
Overview
VCDetect - detect version control software for file paths
Assumes version control data is stored on the file system in plain, unambiguous, per-project fashion. This precludes the ability to detect arcane and offbeat version control software such as cvsnt, svk, and vss.
Constant Summary collapse
- VERSION =
'0.5'
- HOME =
ENV['HOME']
- PARENT_OF_HOME =
File.('..', HOME)
- VC2FILE =
Version control software names (command line tools, as symbols) to version control internal data file
{ accurev: 'site_slice', admsconsole: 'Vault', arx: '_arx', bk: 'BitKeeper', bzr: '.bzr', cleartool: 'default.magic', cmvc: 'vc', cvs: 'CVS', darcs: '_darcs', dcvs: 'DCVSMETA', fossil: '_FOSSIL_', git: '.git', hci: 'harvest.sig', hg: '.hg', mcvs: 'MCVS', mtn: '_MTN', p4: 'depot', plastic: '.plastic', qvcs: 'qvcsMetaData', razor: 'RAZOR_UNIVERSE', rcs: 'RCS', scss: 'SCSS', svn: '.svn', teamware: 'Codemgr_wsdata' }
- FILE2VC =
Version control internal data file to version control software names (command line tools, as symbols)
VC2FILE.invert
- VCS =
Version control software names (command line tools, as symbols)
VC2FILE.keys
- FILES =
Version control internal data files
VC2FILE.values
Class Method Summary collapse
-
.detect(path) ⇒ Object
Detect version control software managing a file path.
Class Method Details
.detect(path) ⇒ Object
Detect version control software managing a file path
Assumes path exists. Assuems path is relative to $HOME.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/vcdetect.rb', line 70 def self.detect(path) parent = File.('..', path) if !File.directory?(path) detect(parent) elsif path == PARENT_OF_HOME :unknown else software = FILES.select do |vc_dir| Dir.new(path).entries.include?(vc_dir) end if software.length == 0 detect(parent) elsif software.length == 1 FILE2VC[software.first] else software.map do |s| FILE2VC[s] end end end end |