Class: Gitlab::Git::Blame
- Inherits:
-
Object
- Object
- Gitlab::Git::Blame
- Defined in:
- lib/gitlab_git/blame.rb
Instance Attribute Summary collapse
-
#blob ⇒ Object
Returns the value of attribute blob.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(repository, sha, path) ⇒ Blame
constructor
A new instance of Blame.
Constructor Details
#initialize(repository, sha, path) ⇒ Blame
Returns a new instance of Blame.
6 7 8 9 10 11 |
# File 'lib/gitlab_git/blame.rb', line 6 def initialize(repository, sha, path) @repo = repository.rugged @blame = Rugged::Blame.new(@repo, path, { newest_commit: sha }) @blob = Blob.find(repository, sha, path) @lines = @blob.data.split("\n") end |
Instance Attribute Details
#blob ⇒ Object
Returns the value of attribute blob.
4 5 6 |
# File 'lib/gitlab_git/blame.rb', line 4 def blob @blob end |
Instance Method Details
#each ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gitlab_git/blame.rb', line 13 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 |