Class: Gitlab::Git::Blame

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_git/blame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, sha, path) ⇒ Blame

Returns a new instance of Blame.



6
7
8
# File 'lib/gitlab_git/blame.rb', line 6

def initialize(repository, sha, path)
  @repository, @sha, @path = repository, sha, path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/gitlab_git/blame.rb', line 4

def path
  @path
end

#repositoryObject

Returns the value of attribute repository.



4
5
6
# File 'lib/gitlab_git/blame.rb', line 4

def repository
  @repository
end

#shaObject

Returns the value of attribute sha.



4
5
6
# File 'lib/gitlab_git/blame.rb', line 4

def sha
  @sha
end

Instance Method Details

#eachObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/gitlab_git/blame.rb', line 10

def each
  raw_blame = Grit::Blob.blame(repository.raw, sha, path)

  raw_blame.each do |commit, lines|
    next unless commit

    commit = Gitlab::Git::Commit.new(commit)
    yield(commit, lines)
  end
end