Diff properties
Diff properties
Stats properties
Diff properties
Stats properties
Diff properties
Diff properties
Stats properties
# File lib/gitlab_git/diff.rb, line 18 def between(repo, from, to) # 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(from, to) repo.diff(common_commit, from).map do |diff| Gitlab::Git::Diff.new(diff) end rescue Grit::Git::GitTimeout [Gitlab::Git::Diff::BROKEN_DIFF] end
# 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
# File lib/gitlab_git/diff.rb, line 42 def serialize_keys @serialize_keys ||= %w(diff new_path old_path a_mode b_mode new_file renamed_file deleted_file).map(&:to_sym) end
# 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
# File lib/gitlab_git/diff.rb, line 60 def init_from_grit(grit) @raw_diff = grit serialize_keys.each do |key| send(:"#{key}=", grit.send(key)) end end
# File lib/gitlab_git/diff.rb, line 68 def init_from_hash(hash) raw_diff = hash.symbolize_keys serialize_keys.each do |key| send(:"#{key}=", raw_diff[key.to_sym]) end end