Class: GitRepo
- Inherits:
-
Object
- Object
- GitRepo
- Defined in:
- lib/git_repo.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path, name = nil) ⇒ GitRepo
constructor
A new instance of GitRepo.
- #latest_local_commit ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(path, name = nil) ⇒ GitRepo
Returns a new instance of GitRepo.
6 7 8 9 10 |
# File 'lib/git_repo.rb', line 6 def initialize(path, name = nil) @path = path @name = name @memoize = {} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/git_repo.rb', line 4 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/git_repo.rb', line 4 def path @path end |
Instance Method Details
#latest_local_commit ⇒ Object
21 22 23 |
# File 'lib/git_repo.rb', line 21 def latest_local_commit run "rev-parse HEAD" end |
#url ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/git_repo.rb', line 12 def url url = run("config --get remote.origin.url") return if url.blank? url.sub!(/\Agit@github\.com:/, "https://github.com/") url.sub!(/\.git\z/, "") url end |