Sha256: c1cfe775da60a585d6d682f6ffb4056f373dc9c3b9a4ffe9f74ce48f118c1053

Contents?: true

Size: 847 Bytes

Versions: 12

Compression:

Stored size: 847 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

        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)
        @diffs = if @commits.size > limit
                   []
                 else
                   Gitlab::Git::Diff.between(repository, head.id, base.id) rescue []
                 end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gitlab_git-4.0.0 lib/gitlab_git/compare.rb
gitlab_git-4.0.0.pre lib/gitlab_git/compare.rb
gitlab_git-3.1.0 lib/gitlab_git/compare.rb
gitlab_git-3.0.1 lib/gitlab_git/compare.rb
gitlab_git-3.0.0 lib/gitlab_git/compare.rb
gitlab_git-3.0.0.rc2 lib/gitlab_git/compare.rb
gitlab_git-3.0.0.rc1 lib/gitlab_git/compare.rb
gitlab_git-3.0.0.beta1 lib/gitlab_git/compare.rb
gitlab_git-3.0.0.pre lib/gitlab_git/compare.rb
gitlab_git-2.3.1 lib/gitlab_git/compare.rb
gitlab_git-2.3.0 lib/gitlab_git/compare.rb
gitlab_git-2.2.0 lib/gitlab_git/compare.rb