Class: Gitlab::Git::Blame
- Inherits:
-
Object
- Object
- Gitlab::Git::Blame
- Defined in:
- lib/gitlab_git/blame.rb
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.
5 6 7 8 9 10 |
# File 'lib/gitlab_git/blame.rb', line 5 def initialize(repository, sha, path) @repo = repository.rugged @blame = Rugged::Blame.new(@repo, path) @blob = @repo.blob_at(sha, path) @lines = @blob.content.split("\n") end |
Instance Method Details
#each ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gitlab_git/blame.rb', line 12 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 |