Class: GitCommands::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/git_commands/repository.rb

Defined Under Namespace

Classes: InvalidError

Constant Summary collapse

LOCKING_FILES =
%w(rebase-merge rebase-apply)

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Repository

Returns a new instance of Repository.



9
10
11
12
# File 'lib/git_commands/repository.rb', line 9

def initialize(path)
  @path = Pathname::new(path.to_s)
  fail InvalidError, "'#{path}' is not a valid GIT repository!" unless valid?
end

Instance Method Details

#locked?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/git_commands/repository.rb', line 18

def locked?
  LOCKING_FILES.any? do |name| 
    File.exists?(@path.join(".git", name))
  end
end

#to_pathObject



14
15
16
# File 'lib/git_commands/repository.rb', line 14

def to_path
  @path.to_s
end