Class: ReaPack::Index::Git::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/reapack/index/git.rb

Instance Method Summary collapse

Constructor Details

#initialize(commit, repo) ⇒ Commit

Returns a new instance of Commit.



135
136
137
138
# File 'lib/reapack/index/git.rb', line 135

def initialize(commit, repo)
  @commit, @repo = commit, repo
  @parent = commit.parents.first
end

Instance Method Details

#==(o) ⇒ Object Also known as: eql?



177
178
179
# File 'lib/reapack/index/git.rb', line 177

def ==(o)
  o && id == o.id
end

#each_diff(&block) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/reapack/index/git.rb', line 140

def each_diff(&block)
  return @diffs.each &block if @diffs

  if @parent
    diff = @parent.diff id
  else
    diff = @commit.diff
  end

  @diffs = diff.each_delta.map {|delta| Git::Diff.new(delta, @repo) }
  @diffs.each &block
end

#filelistObject



173
174
175
# File 'lib/reapack/index/git.rb', line 173

def filelist
  lsfiles @commit.tree
end

#hashObject



183
184
185
# File 'lib/reapack/index/git.rb', line 183

def hash
  id.hash
end

#idObject



153
154
155
# File 'lib/reapack/index/git.rb', line 153

def id
  @commit.oid
end

#inspectObject



187
188
189
# File 'lib/reapack/index/git.rb', line 187

def inspect
  "#<#{self.class} #{id} #{summary}>"
end

#messageObject



161
162
163
# File 'lib/reapack/index/git.rb', line 161

def message
  @commit.message
end

#short_idObject



157
158
159
# File 'lib/reapack/index/git.rb', line 157

def short_id
  id[0...7]
end

#summaryObject



165
166
167
# File 'lib/reapack/index/git.rb', line 165

def summary
  @commit.summary
end

#timeObject



169
170
171
# File 'lib/reapack/index/git.rb', line 169

def time
  @commit.time
end