Class: Zubat::Commit

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sha:, time:) ⇒ Commit

Returns a new instance of Commit.



17
18
19
20
# File 'lib/zubat/commit.rb', line 17

def initialize(sha:, time:)
  @sha = sha
  @time = time
end

Instance Attribute Details

#shaObject (readonly)

Returns the value of attribute sha.



5
6
7
# File 'lib/zubat/commit.rb', line 5

def sha
  @sha
end

#timeObject (readonly)

Returns the value of attribute time.



5
6
7
# File 'lib/zubat/commit.rb', line 5

def time
  @time
end

Class Method Details

.find(files:) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/zubat/commit.rb', line 7

def self.find(files:)
  logs = GitCommandWrapper.new.log(files:)

  commits = logs.map { |log| Zubat::Commit.new(sha: log.sha, time: log.time) }

  commits.reverse!

  commits
end

Instance Method Details

#diff(file:) ⇒ Object



30
31
32
# File 'lib/zubat/commit.rb', line 30

def diff(file:)
  GitCommandWrapper.new.diff(sha: @sha, file:)
end

#exists?(file:) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/zubat/commit.rb', line 22

def exists?(file:)
  GitCommandWrapper.new.exists?(sha: @sha, file:)
end

#show(file:) ⇒ Object



26
27
28
# File 'lib/zubat/commit.rb', line 26

def show(file:)
  GitCommandWrapper.new.show(sha: @sha, file:)
end