Class: Envirobly::Git::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/envirobly/git/commit.rb

Instance Method Summary collapse

Constructor Details

#initialize(ref) ⇒ Commit

Returns a new instance of Commit.



4
5
6
# File 'lib/envirobly/git/commit.rb', line 4

def initialize(ref)
  @ref = ref
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/envirobly/git/commit.rb', line 8

def exists?
  `git cat-file -t #{@ref}`.strip == "commit"
end

#messageObject



16
17
18
# File 'lib/envirobly/git/commit.rb', line 16

def message
  `git log #{@ref} -n1 --pretty=%B`.strip
end

#refObject



12
13
14
# File 'lib/envirobly/git/commit.rb', line 12

def ref
  @normalized_ref ||= `git rev-parse #{@ref}`.strip
end

#timeObject



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

def time
  Time.parse `git log #{@ref} -n1 --date=iso --pretty=format:"%ad"`
end