class OhlohScm::Diff

A Diff represents a change to a single file. It can represent the addition or deletion of a file, or it can represent a modification of the file contents.

OpenHub does not track filename changes. If a file is renamed, OpenHub treats this as the deletion of one file and the creation of another.

OpenHub does not track directories, only the files within directories.

Don't confuse our use of the word “Diff” with a patch file or the output of the console tool 'diff'. This object doesn't have anything to do the actual contents of the file; it's better to think of this object as representing a single line item from a source control log.

Attributes

action[RW]

An action code describing the type of change made to the file. Action codes are copied directly from the Git standard. The action code can be…

'A' added
'M' modified
'D' deleted
from_path[RW]

For Subversion only, a path may be reported as copied from another location. These attributes store the path and revision number of the source of the copy.

from_revision[RW]

For Subversion only, a path may be reported as copied from another location. These attributes store the path and revision number of the source of the copy.

parent_sha1[RW]

The SHA1 hash of the file contents both before and after the change. These must be computed using the same method as Git.

path[RW]

The filename of the changed file, relative to the root of the repository.

sha1[RW]

The SHA1 hash of the file contents both before and after the change. These must be computed using the same method as Git.

Public Class Methods

new(params = {}) click to toggle source
# File lib/ohloh_scm/diff.rb, line 36
def initialize(params = {})
  params.each { |k, v| send(k.to_s + '=', v) if respond_to?(k.to_s + '=') }
end

Public Instance Methods

eql?(other) click to toggle source

eql?() and hash() are implemented so that [].uniq() will work on an array of Diffs.

# File lib/ohloh_scm/diff.rb, line 41
def eql?(other)
  @action.eql?(other.action) && @path.eql?(other.path) &&
    @sha1.eql?(other.sha1) && @parent_sha1.eql?(other.parent_sha1)
end
hash() click to toggle source
# File lib/ohloh_scm/diff.rb, line 46
def hash
  "#{action}|#{path}|#{sha1}|#{parent_sha1}".hash
end