Sha256: b51a69a7741701e5aee23855845a67cb0d3f12cab76132385e85ca37505f1ae7

Contents?: true

Size: 889 Bytes

Versions: 5

Compression:

Stored size: 889 Bytes

Contents

module Gitlab
  module Git
    class Compare
      attr_accessor :commits, :commit, :diffs, :same

      def initialize(repository, from, to, limit = 100)
        @commits, @diffs = [], []
        @commit = nil
        @same = false
        @limit = limit
        @repository = repository

        return unless from && to

        @base = Gitlab::Git::Commit.find(repository, from.try(:strip))
        @head = Gitlab::Git::Commit.find(repository, to.try(:strip))

        return unless @base && @head

        if @base.id == @head.id
          @same = true
          return
        end

        @commit = @head
        @commits = Gitlab::Git::Commit.between(repository, @base.id, @head.id)
      end

      def diffs(paths = nil)
        return [] if @commits.size > @limit
        Gitlab::Git::Diff.between(@repository, @head.id, @base.id, *paths) rescue []
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gitlab_git-5.3.0 lib/gitlab_git/compare.rb
gitlab_git-5.2.0 lib/gitlab_git/compare.rb
gitlab_git-5.1.0 lib/gitlab_git/compare.rb
gitlab_git-5.0.0 lib/gitlab_git/compare.rb
gitlab_git-4.1.0 lib/gitlab_git/compare.rb