Class: Dapp::GitRepo::Base
- Inherits:
-
Object
- Object
- Dapp::GitRepo::Base
- Defined in:
- lib/dapp/git_repo/base.rb
Overview
Base class for any Git repo (remote, gitkeeper, etc)
Instance Attribute Summary collapse
-
#dimg ⇒ Object
readonly
Returns the value of attribute dimg.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #branch ⇒ Object
- #cleanup! ⇒ Object
- #commit_at(commit) ⇒ Object
- #container_path ⇒ Object
- #git_bare ⇒ Object
-
#initialize(dimg, name) ⇒ Base
constructor
A new instance of Base.
- #latest_commit(branch) ⇒ Object
- #old_git_bare(command, **kwargs) ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(dimg, name) ⇒ Base
Returns a new instance of Base.
8 9 10 11 |
# File 'lib/dapp/git_repo/base.rb', line 8 def initialize(dimg, name) @dimg = dimg @name = name end |
Instance Attribute Details
#dimg ⇒ Object (readonly)
Returns the value of attribute dimg.
5 6 7 |
# File 'lib/dapp/git_repo/base.rb', line 5 def dimg @dimg end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/dapp/git_repo/base.rb', line 6 def name @name end |
Instance Method Details
#branch ⇒ Object
41 42 43 |
# File 'lib/dapp/git_repo/base.rb', line 41 def branch .head.name.sub(/^refs\/heads\//, '') end |
#cleanup! ⇒ Object
38 39 |
# File 'lib/dapp/git_repo/base.rb', line 38 def cleanup! end |
#commit_at(commit) ⇒ Object
29 30 31 |
# File 'lib/dapp/git_repo/base.rb', line 29 def commit_at(commit) .lookup(commit).time.to_i end |
#container_path ⇒ Object
13 14 15 |
# File 'lib/dapp/git_repo/base.rb', line 13 def container_path dimg.container_tmp_path "#{name}.git" end |
#git_bare ⇒ Object
21 22 23 |
# File 'lib/dapp/git_repo/base.rb', line 21 def @git_bare ||= Rugged::Repository.new(path, bare: true) end |
#latest_commit(branch) ⇒ Object
33 34 35 36 |
# File 'lib/dapp/git_repo/base.rb', line 33 def latest_commit(branch) return .head.target_id if branch == 'HEAD' .branches[branch].target_id end |
#old_git_bare(command, **kwargs) ⇒ Object
25 26 27 |
# File 'lib/dapp/git_repo/base.rb', line 25 def (command, **kwargs) old_git "--git-dir=#{path} #{command}", **kwargs end |
#path ⇒ Object
17 18 19 |
# File 'lib/dapp/git_repo/base.rb', line 17 def path dimg.tmp_path("#{name}.git").to_s end |