Parent

Gitlab::Git::Diff

Attributes

a_mode[RW]

Diff properties

b_mode[RW]

Diff properties

deleted_file[RW]

Stats properties

diff[RW]

Diff properties

new_file[RW]

Stats properties

new_path[RW]

Diff properties

old_path[RW]

Diff properties

raw_diff[RW]
renamed_file[RW]

Stats properties

Public Class Methods

between(repo, head, base, *paths) click to toggle source
# File lib/gitlab_git/diff.rb, line 18
def between(repo, head, base, *paths)
  # Only show what is new in the source branch compared to the target branch, not the other way around.
  # The linex below with merge_base is equivalent to diff with three dots (git diff branch1...branch2)
  # From the git documentation: "git diff A...B" is equivalent to "git diff $(git-merge-base A B) B"
  common_commit = repo.merge_base_commit(head, base)

  repo.diff(common_commit, head, *paths).map do |diff|
    Gitlab::Git::Diff.new(diff)
  end
rescue Grit::Git::GitTimeout
  raise TimeoutError.new("Diff.between exited with timeout")
end
new(raw_diff) click to toggle source
# File lib/gitlab_git/diff.rb, line 32
def initialize(raw_diff)
  raise "Nil as raw diff passed" unless raw_diff

  if raw_diff.is_a?(Hash)
    init_from_hash(raw_diff)
  else
    init_from_grit(raw_diff)
  end
end

Public Instance Methods

serialize_keys() click to toggle source
# File lib/gitlab_git/diff.rb, line 42
def serialize_keys
  @serialize_keys ||= %(diff new_path old_path a_mode b_mode new_file renamed_file deleted_file).map(&:to_sym)
end
to_hash() click to toggle source
# File lib/gitlab_git/diff.rb, line 46
def to_hash
  hash = {}

  keys = serialize_keys

  keys.each do |key|
    hash[key] = send(key)
  end

  hash
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.