diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /lib/gitlab/blame.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) | |
download | gitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'lib/gitlab/blame.rb')
-rw-r--r-- | lib/gitlab/blame.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/gitlab/blame.rb b/lib/gitlab/blame.rb index 78a8f39e143..e210c18e3d1 100644 --- a/lib/gitlab/blame.rb +++ b/lib/gitlab/blame.rb @@ -2,11 +2,16 @@ module Gitlab class Blame - attr_accessor :blob, :commit + attr_accessor :blob, :commit, :range - def initialize(blob, commit) + def initialize(blob, commit, range: nil) @blob = blob @commit = commit + @range = range + end + + def first_line + range&.first || 1 end def groups(highlight: true) @@ -14,14 +19,14 @@ module Gitlab groups = [] current_group = nil - i = 0 - blame.each do |commit, line| + i = first_line - 1 + blame.each do |commit, line, previous_path| commit = Commit.new(commit, project) commit.lazy_author # preload author if prev_sha != commit.sha groups << current_group if current_group - current_group = { commit: commit, lines: [] } + current_group = { commit: commit, lines: [], previous_path: previous_path } end current_group[:lines] << (highlight ? highlighted_lines[i].html_safe : line) @@ -37,7 +42,7 @@ module Gitlab private def blame - @blame ||= Gitlab::Git::Blame.new(repository, @commit.id, @blob.path) + @blame ||= Gitlab::Git::Blame.new(repository, @commit.id, @blob.path, range: range) end def highlighted_lines |