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.



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

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

Instance Attribute Details

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#repositoryObject

Returns the value of attribute repository.



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

def repository
  @repository
end

#shaObject

Returns the value of attribute sha.



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

def sha
  @sha
end

Instance Method Details

#eachObject



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

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

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

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