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
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #branch ⇒ Object
- #cleanup! ⇒ Object
- #commit_at(commit) ⇒ Object
- #container_build_dir_path ⇒ Object
- #dir_path ⇒ Object
- #exist_in_commit?(path, commit) ⇒ Boolean
- #git_bare(command, **kwargs) ⇒ Object
-
#initialize(application, name) ⇒ Base
constructor
A new instance of Base.
- #latest_commit(branch) ⇒ Object
Constructor Details
#initialize(application, name) ⇒ Base
Returns a new instance of Base.
8 9 10 11 |
# File 'lib/dapp/git_repo/base.rb', line 8 def initialize(application, name) @application = application @name = name end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
5 6 7 |
# File 'lib/dapp/git_repo/base.rb', line 5 def application @application 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
40 41 42 |
# File 'lib/dapp/git_repo/base.rb', line 40 def branch ('rev-parse --abbrev-ref HEAD').stdout.strip end |
#cleanup! ⇒ Object
37 38 |
# File 'lib/dapp/git_repo/base.rb', line 37 def cleanup! end |
#commit_at(commit) ⇒ Object
25 26 27 |
# File 'lib/dapp/git_repo/base.rb', line 25 def commit_at(commit) Time.at Integer ("show -s --format=%ct #{commit}").stdout.strip end |
#container_build_dir_path ⇒ Object
13 14 15 |
# File 'lib/dapp/git_repo/base.rb', line 13 def container_build_dir_path application.container_build_path "#{name}.git" end |
#dir_path ⇒ Object
17 18 19 |
# File 'lib/dapp/git_repo/base.rb', line 17 def dir_path application.build_path "#{name}.git" end |
#exist_in_commit?(path, commit) ⇒ Boolean
33 34 35 |
# File 'lib/dapp/git_repo/base.rb', line 33 def exist_in_commit?(path, commit) ("cat-file -e #{commit}:#{path}", returns: [0, 128]).status.success? end |
#git_bare(command, **kwargs) ⇒ Object
21 22 23 |
# File 'lib/dapp/git_repo/base.rb', line 21 def (command, **kwargs) git "--git-dir=#{dir_path} #{command}", **kwargs end |
#latest_commit(branch) ⇒ Object
29 30 31 |
# File 'lib/dapp/git_repo/base.rb', line 29 def latest_commit(branch) ("rev-parse #{branch}").stdout.strip end |