class GitCommands::Repository
Constants
- LOCKING_FILES
Public Class Methods
new(path)
click to toggle source
# File lib/git_commands/repository.rb, line 10 def initialize(path) @path = Pathname::new(path.to_s) fail PathError, "'#{path}' must be an absolute path!" unless @path.absolute? fail InvalidError, "'#{path}' is not a valid GIT repository!" unless valid? end
Public Instance Methods
locked?()
click to toggle source
# File lib/git_commands/repository.rb, line 20 def locked? LOCKING_FILES.any? do |name| @path.join(".git", name).exist? end end
to_path()
click to toggle source
# File lib/git_commands/repository.rb, line 16 def to_path @path.to_s end
unlock()
click to toggle source
# File lib/git_commands/repository.rb, line 26 def unlock Dir.chdir(self) do `git rebase --abort` end end
Private Instance Methods
valid?()
click to toggle source
# File lib/git_commands/repository.rb, line 32 def valid? @path.directory? && work_tree? end
work_tree?()
click to toggle source
# File lib/git_commands/repository.rb, line 36 def work_tree? Dir.chdir(self) do `git rev-parse --is-inside-work-tree 2> /dev/null`.strip == "true" end end