Method: Brigit.parent_of
- Defined in:
- lib/brigit.rb
.parent_of(path) ⇒ Object
Note: Doesn’t validate against .gitmodules or .git/config
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/brigit.rb', line 25 def self.parent_of(path) components = path.split(File::SEPARATOR) components.pop matched = [] components.inject(['']) do |list, component| list << component check_path = File.join(*list.clone.push('.git')) matched << File.dirname(check_path) if File.exists?(check_path) list end matched.pop end |