Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswaldo Ferreira <oswluizf@gmail.com>2016-11-03 02:49:13 +0300
committerOswaldo Ferreira <oswluizf@gmail.com>2016-12-03 00:18:17 +0300
commitf272ee6eba37548cbd8919139d583a71ffdac8dc (patch)
tree78d1e9a5e7bcf4935e8efbe4e5e6e4b976dfc9e8 /app/models/commit.rb
parent3ebb815a38ba86e4133557f77b94c292c8fc2e7e (diff)
Add shorthand support to gitlab markdown references
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb22
1 files changed, 12 insertions, 10 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 176c524cf7b..248140f421b 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -92,19 +92,11 @@ class Commit
end
def to_reference(from_project = nil)
- if cross_project_reference?(from_project)
- project.to_reference + self.class.reference_prefix + self.id
- else
- self.id
- end
+ commit_reference(from_project, id)
end
def reference_link_text(from_project = nil)
- if cross_project_reference?(from_project)
- project.to_reference + self.class.reference_prefix + self.short_id
- else
- self.short_id
- end
+ commit_reference(from_project, short_id)
end
def diff_line_count
@@ -329,6 +321,16 @@ class Commit
private
+ def commit_reference(from_project, referable_commit_id)
+ reference = project.to_reference(from_project)
+
+ if reference.present?
+ "#{reference}#{self.class.reference_prefix}#{referable_commit_id}"
+ else
+ referable_commit_id
+ end
+ end
+
def find_author_by_any_email
User.find_by_any_email(author_email.downcase)
end