Sha256: 7baac1c8a3bfebf1bdc3b8de769393dd7018eadd3eaabf68c2a84c58e4547ace
Contents?: true
Size: 1.33 KB
Versions: 17
Compression:
Stored size: 1.33 KB
Contents
module Gitlab module Git class Compare attr_reader :commits, :diffs, :same, :timeout, :head, :base def initialize(repository, base, head) @commits, @diffs = [], [] @same = false @repository = repository @timeout = false return unless base && head @base = Gitlab::Git::Commit.find(repository, base.try(:strip)) @head = Gitlab::Git::Commit.find(repository, head.try(:strip)) return unless @base && @head if @base.id == @head.id @same = true return end @commits = Gitlab::Git::Commit.between(repository, @base.id, @head.id) end def diffs(paths = nil) unless @head && @base return [] end # Try to collect diff only if diffs is empty # Otherwise return cached version if @diffs.empty? && @timeout == false begin @diffs = Gitlab::Git::Diff.between(@repository, @head.id, @base.id, *paths) rescue Gitlab::Git::Diff::TimeoutError => ex @diffs = [] @timeout = true end end @diffs end # Check if diff is empty because it is actually empty # and not because its impossible to get it def empty_diff? diffs.empty? && timeout == false end end end end
Version data entries
17 entries across 17 versions & 1 rubygems