Sha256: dd149249f4450fd9cd5ee104c8f10d0013d50f4644acf325014171b499cda41f

Contents?: true

Size: 978 Bytes

Versions: 12

Compression:

Stored size: 978 Bytes

Contents

module Gitlab
  module Git
    class Compare
      attr_reader :head, :base

      def initialize(repository, base, head)
        @repository = repository

        unless base && head
          @commits = []
          return
        end

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

        @commits = [] unless @base && @head
        @commits = [] if same
      end

      def same
        @base && @head && @base.id == @head.id
      end

      def commits
        return @commits if defined?(@commits)

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

      def diffs(options = {})
        unless @head && @base
          return Gitlab::Git::DiffCollection.new([])
        end

        paths = options.delete(:paths) || []
        Gitlab::Git::Diff.between(@repository, @head.id, @base.id, options, *paths)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gitlab_git-10.6.7 lib/gitlab_git/compare.rb
gitlab_git-10.6.6 lib/gitlab_git/compare.rb
gitlab_git-10.6.5 lib/gitlab_git/compare.rb
gitlab_git-10.6.4 lib/gitlab_git/compare.rb
gitlab_git-10.6.3 lib/gitlab_git/compare.rb
gitlab_git-10.6.2 lib/gitlab_git/compare.rb
gitlab_git-10.6.1 lib/gitlab_git/compare.rb
gitlab_git-10.6.0 lib/gitlab_git/compare.rb
gitlab_git-10.5.0 lib/gitlab_git/compare.rb
gitlab_git-10.4.7 lib/gitlab_git/compare.rb
gitlab_git-10.4.6 lib/gitlab_git/compare.rb
gitlab_git-10.4.5 lib/gitlab_git/compare.rb