summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorClement Ho <clemmakesapps@gmail.com>2018-01-17 21:01:06 +0000
committerClement Ho <clemmakesapps@gmail.com>2018-01-17 21:01:06 +0000
commit195448c28c3a3238126e9e21f7b1abb8f186980e (patch)
tree0d2d760317e17aeb3a7dc0d74ffc5d1978a00cb0 /app/models/commit.rb
parent525b178e5d5cfe127fe2cfc6f211725e6c3089ae (diff)
parentf351cc28c2c878bf491bb0886be65bf35b58b261 (diff)
downloadgitlab-ce-dispatcher-project-mr-edit.tar.gz
Merge branch 'master' into 'dispatcher-project-mr-edit'dispatcher-project-mr-edit
# Conflicts: # app/assets/javascripts/dispatcher.js
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 39d7f5b159d..2d2d89af030 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -238,6 +238,10 @@ class Commit
notes.includes(:author)
end
+ def merge_requests
+ @merge_requests ||= project.merge_requests.by_commit_sha(sha)
+ end
+
def method_missing(method, *args, &block)
@raw.__send__(method, *args, &block) # rubocop:disable GitlabSecurity/PublicSend
end
@@ -342,10 +346,11 @@ class Commit
@merged_merge_request_hash[current_user]
end
- def has_been_reverted?(current_user, noteable = self)
+ def has_been_reverted?(current_user, notes_association = nil)
ext = all_references(current_user)
+ notes_association ||= notes_with_associations
- noteable.notes_with_associations.system.each do |note|
+ notes_association.system.each do |note|
note.all_references(current_user, extractor: ext)
end
@@ -367,19 +372,19 @@ class Commit
# uri_type('doc/README.md') # => :blob
# uri_type('doc/logo.png') # => :raw
# uri_type('doc/api') # => :tree
- # uri_type('not/found') # => :nil
+ # uri_type('not/found') # => nil
#
# Returns a symbol
def uri_type(path)
- entry = @raw.rugged_tree_entry(path)
+ entry = @raw.tree_entry(path)
+ return unless entry
+
if entry[:type] == :blob
blob = ::Blob.decorate(Gitlab::Git::Blob.new(name: entry[:name]), @project)
blob.image? || blob.video? ? :raw : :blob
else
entry[:type]
end
- rescue Rugged::TreeError
- nil
end
def raw_diffs(*args)