diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 21:18:33 +0300 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /lib/gitlab/git | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'lib/gitlab/git')
-rw-r--r-- | lib/gitlab/git/blame.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/git/commit.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/git/wiki_file.rb | 13 |
3 files changed, 19 insertions, 4 deletions
diff --git a/lib/gitlab/git/blame.rb b/lib/gitlab/git/blame.rb index b118eda37f8..9e24306c05e 100644 --- a/lib/gitlab/git/blame.rb +++ b/lib/gitlab/git/blame.rb @@ -38,9 +38,11 @@ module Gitlab if line[0, 1] == "\t" lines << line[1, line.size] elsif m = /^(\w{40}) (\d+) (\d+)/.match(line) - commit_id, old_lineno, lineno = m[1], m[2].to_i, m[3].to_i + # Removed these instantiations for performance but keeping them for reference: + # commit_id, old_lineno, lineno = m[1], m[2].to_i, m[3].to_i + commit_id = m[1] commits[commit_id] = nil unless commits.key?(commit_id) - info[lineno] = [commit_id, old_lineno] + info[m[3].to_i] = [commit_id, m[2].to_i] end end @@ -50,8 +52,7 @@ module Gitlab # get it together info.sort.each do |lineno, (commit_id, old_lineno)| - commit = commits[commit_id] - final << BlameLine.new(lineno, old_lineno, commit, lines[lineno - 1]) + final << BlameLine.new(lineno, old_lineno, commits[commit_id], lines[lineno - 1]) end @lines = final diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index 35c3dc5b0b3..ff99803d8de 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -20,6 +20,7 @@ module Gitlab ].freeze attr_accessor(*SERIALIZE_KEYS) + attr_reader :repository def ==(other) return false unless other.is_a?(Gitlab::Git::Commit) diff --git a/lib/gitlab/git/wiki_file.rb b/lib/gitlab/git/wiki_file.rb index c05a5adc00c..7f09173f05c 100644 --- a/lib/gitlab/git/wiki_file.rb +++ b/lib/gitlab/git/wiki_file.rb @@ -12,6 +12,19 @@ module Gitlab @name = gitaly_file.name @path = gitaly_file.path end + + def self.from_blob(blob) + hash = { + name: File.basename(blob.name), + mime_type: blob.mime_type, + path: blob.path, + raw_data: blob.data + } + + gitaly_file = Gitlab::GitalyClient::WikiFile.new(hash) + + Gitlab::Git::WikiFile.new(gitaly_file) + end end end end |