Sha256: 834a6f4a4ac3bb48b25c93d441c7a5d34fb86c6d899e50332595d7c2703d4246

Contents?: true

Size: 642 Bytes

Versions: 4

Compression:

Stored size: 642 Bytes

Contents

module Gitlab
  module Git
    class Blame

      def initialize(repository, sha, path)
        @repo = repository.rugged
        @blame = Rugged::Blame.new(@repo, path, { :newest_commit => sha })
        @blob = @repo.blob_at(sha, path)
        @lines = @blob.content.split("\n")
      end

      def each
        @blame.each do |blame|
          from = blame[:final_start_line_number] - 1
          commit = @repo.lookup(blame[:final_commit_id])

          yield(Gitlab::Git::Commit.new(commit),
              @lines[from, blame[:lines_in_hunk]] || [],
              blame[:final_start_line_number])
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gitlab_git-7.0.1 lib/gitlab_git/blame.rb
gitlab_git-7.0.0 lib/gitlab_git/blame.rb
gitlab_git-7.0.0.rc15 lib/gitlab_git/blame.rb
gitlab_git-7.0.0.rc14 lib/gitlab_git/blame.rb