Class: Repository

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

Defined Under Namespace

Classes: GitCommandFailedError, InvalidGitRepositoryError, NoPathProvidedError, NoSuchPathError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Repository

Returns a new instance of Repository.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/auto_tagger/repository.rb', line 10

def initialize(path)
  if path.to_s.strip == ""
    raise NoPathProvidedError
  elsif ! File.exists?(path)
    raise NoSuchPathError
  elsif ! File.exists?(File.join(path, ".git"))
    raise InvalidGitRepositoryError
  else
    @path = path
  end
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/auto_tagger/repository.rb', line 8

def path
  @path
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/auto_tagger/repository.rb', line 22

def ==(other)
  other.is_a?(Repository) && other.path == path
end

#commit_for(tag) ⇒ Object



30
31
32
# File 'lib/auto_tagger/repository.rb', line 30

def commit_for(tag)
  Commander.execute(path, "git --no-pager log #{tag} --pretty=oneline -1")
end

#run(cmd) ⇒ Object



34
35
36
# File 'lib/auto_tagger/repository.rb', line 34

def run(cmd)
  Commander.execute(path, cmd)
end

#run!(cmd) ⇒ Object



38
39
40
# File 'lib/auto_tagger/repository.rb', line 38

def run!(cmd)
  Commander.execute!(path, cmd) || raise(GitCommandFailedError)
end

#tagsObject



26
27
28
# File 'lib/auto_tagger/repository.rb', line 26

def tags
  @tags ||= Tag.new(self)
end