Class: Dragnet::Repository
- Inherits:
-
BaseRepository
- Object
- BaseRepository
- Dragnet::Repository
- Extended by:
- Forwardable
- Defined in:
- lib/dragnet/repository.rb
Overview
A small wrapper around a Git Repository object. It provides some useful methods needed during the verify process as well as for reporting.
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
Attributes inherited from BaseRepository
Instance Method Summary collapse
-
#branches_with(commit) ⇒ Array<Git::Branch>
Returns an array of all the branches that include the given commit.
-
#branches_with_head ⇒ Array<Git::Branch>
Returns an array of all the branches that include the current HEAD.
-
#head ⇒ Git::Object::Commit
The
Commit
object at theHEAD
of the repository. -
#initialize(path:) ⇒ Repository
constructor
Creates a new instance of the class.
-
#multi? ⇒ FalseClass
It always returns false.
-
#remote_uri_path ⇒ String
Returns the URI path of the repository (extracted from its first remote [assumed to be the origin]).
Methods inherited from BaseRepository
#branch, #branches, #diff, #repositories
Constructor Details
#initialize(path:) ⇒ Repository
Creates a new instance of the class. Tries to open the given path as a Git repository.
22 23 24 25 |
# File 'lib/dragnet/repository.rb', line 22 def initialize(path:) super @git = Git.open(path) end |
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
14 15 16 |
# File 'lib/dragnet/repository.rb', line 14 def git @git end |
Instance Method Details
#branches_with(commit) ⇒ Array<Git::Branch>
Returns an array of all the branches that include the given commit.
52 53 54 |
# File 'lib/dragnet/repository.rb', line 52 def branches_with(commit) branches.select { |branch| branch.contains?(commit) } end |
#branches_with_head ⇒ Array<Git::Branch>
Returns an array of all the branches that include the current HEAD.
59 60 61 |
# File 'lib/dragnet/repository.rb', line 59 def branches_with_head @branches_with_head ||= branches_with(head.sha) end |
#head ⇒ Git::Object::Commit
Returns The Commit
object at the HEAD
of the repository.
29 30 31 |
# File 'lib/dragnet/repository.rb', line 29 def head @head ||= git.object('HEAD') end |
#multi? ⇒ FalseClass
Returns It always returns false.
44 45 46 |
# File 'lib/dragnet/repository.rb', line 44 def multi? false end |
#remote_uri_path ⇒ String
Returns the URI path of the repository (extracted from its first remote [assumed to be the origin]). Example:
ssh://jenkins@gerrit.int.esrlabs.com:29418/tools/dragnet -> /tools/dragnet
39 40 41 |
# File 'lib/dragnet/repository.rb', line 39 def remote_uri_path Git::URL.parse(git.remotes.first.url).path end |