Class: AutoTagger::Git::Repo
- Inherits:
-
Object
- Object
- AutoTagger::Git::Repo
show all
- Defined in:
- lib/auto_tagger/git/repo.rb
Overview
A class that represents a git repo
repo.refs.create name, sha
repo.refs.all
repo.refs.push origin, pattern
repo.refs.fetch origin, pattern
Defined Under Namespace
Classes: GitCommandFailedError, InvalidGitRepositoryError, NoPathProvidedError, NoSuchPathError
Instance Method Summary
collapse
Constructor Details
#initialize(given_path, options = {}) ⇒ Repo
Returns a new instance of Repo.
25
26
27
28
29
30
|
# File 'lib/auto_tagger/git/repo.rb', line 25
def initialize(given_path, options = {})
@given_path = given_path
@execute_commands = options.fetch(:execute_commands, true)
@verbose = options[:verbose]
@executable = options[:executable] || "git"
end
|
Instance Method Details
#==(other) ⇒ Object
44
45
46
|
# File 'lib/auto_tagger/git/repo.rb', line 44
def ==(other)
other.is_a?(AutoTagger::Git::Repo) && other.path == path
end
|
#exec(cmd) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/auto_tagger/git/repo.rb', line 56
def exec(cmd)
if @execute_commands
commander.execute(git_command(cmd)) || raise(GitCommandFailedError)
else
commander.print(git_command(cmd))
end
end
|
#latest_commit_sha ⇒ Object
48
49
50
|
# File 'lib/auto_tagger/git/repo.rb', line 48
def latest_commit_sha
read("rev-parse HEAD").strip
end
|
#path ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/auto_tagger/git/repo.rb', line 32
def path
return @path if @path
raise NoPathProvidedError if @given_path.to_s.strip == ""
raise NoSuchPathError if !File.exists?(@given_path)
raise InvalidGitRepositoryError if !File.exists?(File.join(@given_path, ".git"))
@path = @given_path
end
|
#read(cmd) ⇒ Object
52
53
54
|
# File 'lib/auto_tagger/git/repo.rb', line 52
def read(cmd)
commander.read(git_command(cmd))
end
|
#refs ⇒ Object
40
41
42
|
# File 'lib/auto_tagger/git/repo.rb', line 40
def refs
RefSet.new(self)
end
|