Class: Avm::Git::Commit

Inherits:
Object
  • Object
show all
Includes:
EacRubyUtils::SimpleCache
Defined in:
lib/avm/git/commit.rb,
lib/avm/git/commit/file.rb,
lib/avm/git/commit/deploy.rb,
lib/avm/git/commit/diff_tree_line.rb

Defined Under Namespace

Classes: Deploy, DiffTreeLine, File

Constant Summary collapse

FIELDS =
{
  author_name: '%an', author_email: '%ae', author_date: '%ai',
  subject: '%s',
  author_all: '%an <%ae>, %ai',
  commiter_name: '%cn', commiter_email: '%ce', commiter_date: '%ci',
  commiter_all: '%cn <%ce>, %ci'
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(git, sha1) ⇒ Commit

Returns a new instance of Commit.



22
23
24
25
# File 'lib/avm/git/commit.rb', line 22

def initialize(git, sha1)
  @git = git
  @sha1 = sha1
end

Instance Attribute Details

#gitObject (readonly)

Returns the value of attribute git.



20
21
22
# File 'lib/avm/git/commit.rb', line 20

def git
  @git
end

#sha1Object (readonly)

Returns the value of attribute sha1.



20
21
22
# File 'lib/avm/git/commit.rb', line 20

def sha1
  @sha1
end

Class Method Details

.target_url_to_env_path(target_url) ⇒ Object



13
14
15
16
17
# File 'lib/avm/git/commit/deploy.rb', line 13

def target_url_to_env_path(target_url)
  uri = ::Addressable::URI.parse(target_url)
  uri.scheme = 'file' if uri.scheme.blank?
  [uri_to_env(uri), uri.path]
end

Instance Method Details

#deploy_to_env_path(target_env, target_path) ⇒ Object



30
31
32
# File 'lib/avm/git/commit/deploy.rb', line 30

def deploy_to_env_path(target_env, target_path)
  Deploy.new(self, target_env, target_path)
end

#deploy_to_url(target_url) ⇒ Object



34
35
36
# File 'lib/avm/git/commit/deploy.rb', line 34

def deploy_to_url(target_url)
  Deploy.new(self, *self.class.target_url_to_env_path(target_url))
end

#files_size_uncachedObject



41
42
43
# File 'lib/avm/git/commit.rb', line 41

def files_size_uncached
  files.inject(0) { |a, e| a + e.dst_size }
end

#files_uncachedObject



37
38
39
# File 'lib/avm/git/commit.rb', line 37

def files_uncached
  diff_tree_execute.each_line.map { |line| ::Avm::Git::Commit::File.new(git, line) }
end

#format(format) ⇒ Object



27
28
29
# File 'lib/avm/git/commit.rb', line 27

def format(format)
  git.execute!('--no-pager', 'log', '-1', "--pretty=format:#{format}", sha1).strip
end

#root_child?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/avm/git/commit.rb', line 45

def root_child?
  format('%P').blank?
end