Class: Dir
- Inherits:
-
Object
- Object
- Dir
- Defined in:
- lib/m-git/foundation/dir.rb
Class Method Summary collapse
-
.is_git_repo?(path) ⇒ Boolean
检查传入路径是不是git仓库.
- .is_in_git_repo?(path) ⇒ Boolean
Class Method Details
.is_git_repo?(path) ⇒ Boolean
检查传入路径是不是git仓库
8 9 10 11 12 |
# File 'lib/m-git/foundation/dir.rb', line 8 def self.is_git_repo?(path) return false unless File.directory?(path) git_dir = File.join(path, '.git') File.directory?(git_dir) end |
.is_in_git_repo?(path) ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/m-git/foundation/dir.rb', line 14 def self.is_in_git_repo?(path) check_path = path result = is_git_repo?(check_path) while !result check_path = File.dirname(check_path) break if check_path == '/' result = is_git_repo?(check_path) end result end |