Class: Envirobly::Git::Commit
Direct Known Subclasses
Defined Under Namespace
Classes: OUTPUT
Instance Method Summary collapse
- #archive_and_upload(bucket:, credentials:) ⇒ Object
- #dir_exists?(path) ⇒ Boolean
- #exists? ⇒ Boolean
- #file_content(path) ⇒ Object
- #file_exists?(path) ⇒ Boolean
-
#initialize(ref, working_dir: Dir.getwd) ⇒ Commit
constructor
A new instance of Commit.
- #message ⇒ Object
- #objects_with_checksum_at(path) ⇒ Object
- #ref ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize(ref, working_dir: Dir.getwd) ⇒ Commit
Returns a new instance of Commit.
5 6 7 8 |
# File 'lib/envirobly/git/commit.rb', line 5 def initialize(ref, working_dir: Dir.getwd) @ref = ref @working_dir = working_dir end |
Instance Method Details
#archive_and_upload(bucket:, credentials:) ⇒ Object
44 45 46 |
# File 'lib/envirobly/git/commit.rb', line 44 def archive_and_upload(bucket:, credentials:) git(%(archive --format=tar.gz #{ref} | #{credentials.as_inline_env_vars} aws s3 cp - #{archive_uri(bucket)})) end |
#dir_exists?(path) ⇒ Boolean
30 31 32 33 |
# File 'lib/envirobly/git/commit.rb', line 30 def dir_exists?(path) suffix = path.end_with?("/") ? nil : "/" git(%(cat-file -t #{@ref}:#{path}#{suffix})).stdout.strip == "tree" end |
#exists? ⇒ Boolean
10 11 12 |
# File 'lib/envirobly/git/commit.rb', line 10 def exists? git(%(cat-file -t #{@ref})).stdout.strip == "commit" end |
#file_content(path) ⇒ Object
35 36 37 |
# File 'lib/envirobly/git/commit.rb', line 35 def file_content(path) git(%(show #{@ref}:#{path})).stdout end |
#file_exists?(path) ⇒ Boolean
26 27 28 |
# File 'lib/envirobly/git/commit.rb', line 26 def file_exists?(path) git(%(cat-file -t #{@ref}:#{path})).stdout.strip == "blob" end |
#message ⇒ Object
18 19 20 |
# File 'lib/envirobly/git/commit.rb', line 18 def git(%(log #{@ref} -n1 --pretty=%B)).stdout.strip end |
#objects_with_checksum_at(path) ⇒ Object
39 40 41 42 |
# File 'lib/envirobly/git/commit.rb', line 39 def objects_with_checksum_at(path) git(%{ls-tree #{@ref} --format='%(objectname) %(path)' #{path}}).stdout.lines.map(&:chomp). reject { _1.split(" ").last == Envirobly::Config::DIR } end |
#ref ⇒ Object
14 15 16 |
# File 'lib/envirobly/git/commit.rb', line 14 def ref @normalized_ref ||= git(%(rev-parse #{@ref})).stdout.strip end |