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:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb32
-rw-r--r--app/helpers/award_emoji_helper.rb8
-rw-r--r--app/helpers/blob_helper.rb114
-rw-r--r--app/helpers/ci_status_helper.rb25
-rw-r--r--app/helpers/events_helper.rb5
-rw-r--r--app/helpers/icons_helper.rb5
-rw-r--r--app/helpers/issuables_helper.rb11
-rw-r--r--app/helpers/markup_helper.rb (renamed from app/helpers/gitlab_markdown_helper.rb)148
-rw-r--r--app/helpers/merge_requests_helper.rb15
-rw-r--r--app/helpers/projects_helper.rb7
-rw-r--r--app/helpers/services_helper.rb4
-rw-r--r--app/helpers/snippets_helper.rb8
-rw-r--r--app/helpers/submodule_helper.rb12
-rw-r--r--app/helpers/todos_helper.rb12
-rw-r--r--app/helpers/tree_helper.rb4
15 files changed, 249 insertions, 161 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e5b811f3300..fff57472a4f 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -196,38 +196,6 @@ module ApplicationHelper
end
end
- def render_markup(file_name, file_content)
- if gitlab_markdown?(file_name)
- Hamlit::RailsHelpers.preserve(markdown(file_content))
- elsif asciidoc?(file_name)
- asciidoc(file_content)
- elsif plain?(file_name)
- content_tag :pre, class: 'plain-readme' do
- file_content
- end
- else
- other_markup(file_name, file_content)
- end
- rescue RuntimeError
- simple_format(file_content)
- end
-
- def plain?(filename)
- Gitlab::MarkupHelper.plain?(filename)
- end
-
- def markup?(filename)
- Gitlab::MarkupHelper.markup?(filename)
- end
-
- def gitlab_markdown?(filename)
- Gitlab::MarkupHelper.gitlab_markdown?(filename)
- end
-
- def asciidoc?(filename)
- Gitlab::MarkupHelper.asciidoc?(filename)
- end
-
def promo_host
'about.gitlab.com'
end
diff --git a/app/helpers/award_emoji_helper.rb b/app/helpers/award_emoji_helper.rb
index 167b09e678f..024cf38469e 100644
--- a/app/helpers/award_emoji_helper.rb
+++ b/app/helpers/award_emoji_helper.rb
@@ -1,10 +1,14 @@
module AwardEmojiHelper
def toggle_award_url(awardable)
- return url_for([:toggle_award_emoji, awardable]) unless @project
+ return url_for([:toggle_award_emoji, awardable]) unless @project || awardable.is_a?(Note)
if awardable.is_a?(Note)
# We render a list of notes very frequently and calling the specific method is a lot faster than the generic one (4.5x)
- toggle_award_emoji_namespace_project_note_url(@project.namespace, @project, awardable.id)
+ if awardable.for_personal_snippet?
+ toggle_award_emoji_snippet_note_path(awardable.noteable, awardable)
+ else
+ toggle_award_emoji_namespace_project_note_path(@project.namespace, @project, awardable.id)
+ end
else
url_for([:toggle_award_emoji, @project.namespace.becomes(Namespace), @project, awardable])
end
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 4b3ab03a69c..377b080b3c6 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -14,15 +14,6 @@ module BlobHelper
options[:link_opts])
end
- def fork_path(project = @project, ref = @ref, path = @path, options = {})
- continue_params = {
- to: edit_path,
- notice: edit_in_new_fork_notice,
- notice_now: edit_in_new_fork_notice_now
- }
- namespace_project_forks_path(project.namespace, project, namespace_key: current_user.namespace.id, continue: continue_params)
- end
-
def edit_blob_link(project = @project, ref = @ref, path = @path, options = {})
blob = options.delete(:blob)
blob ||= project.repository.blob_at(ref, path) rescue nil
@@ -37,7 +28,16 @@ module BlobHelper
elsif !current_user || (current_user && can_modify_blob?(blob, project, ref))
link_to 'Edit', edit_path(project, ref, path, options), class: "#{common_classes} btn-sm"
elsif current_user && can?(current_user, :fork_project, project)
- button_tag 'Edit', class: "#{common_classes} js-edit-blob-link-fork-toggler"
+ continue_params = {
+ to: edit_path(project, ref, path, options),
+ notice: edit_in_new_fork_notice,
+ notice_now: edit_in_new_fork_notice_now
+ }
+ fork_path = namespace_project_forks_path(project.namespace, project, namespace_key: current_user.namespace.id, continue: continue_params)
+
+ button_tag 'Edit',
+ class: "#{common_classes} js-edit-blob-link-fork-toggler",
+ data: { action: 'edit', fork_path: fork_path }
end
end
@@ -48,21 +48,25 @@ module BlobHelper
return unless blob
+ common_classes = "btn btn-#{btn_class}"
+
if !on_top_of_branch?(project, ref)
- button_tag label, class: "btn btn-#{btn_class} disabled has-tooltip", title: "You can only #{action} files when you are on a branch", data: { container: 'body' }
- elsif blob.lfs_pointer?
- button_tag label, class: "btn btn-#{btn_class} disabled has-tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: { container: 'body' }
+ button_tag label, class: "#{common_classes} disabled has-tooltip", title: "You can only #{action} files when you are on a branch", data: { container: 'body' }
+ elsif blob.valid_lfs_pointer?
+ button_tag label, class: "#{common_classes} disabled has-tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: { container: 'body' }
elsif can_modify_blob?(blob, project, ref)
- button_tag label, class: "btn btn-#{btn_class}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal'
+ button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal'
elsif can?(current_user, :fork_project, project)
continue_params = {
- to: request.fullpath,
+ to: request.fullpath,
notice: edit_in_new_fork_notice + " Try to #{action} this file again.",
notice_now: edit_in_new_fork_notice_now
}
fork_path = namespace_project_forks_path(project.namespace, project, namespace_key: current_user.namespace.id, continue: continue_params)
- link_to label, fork_path, class: "btn btn-#{btn_class}", method: :post
+ button_tag label,
+ class: "#{common_classes} js-edit-blob-link-fork-toggler",
+ data: { action: action, fork_path: fork_path }
end
end
@@ -91,7 +95,7 @@ module BlobHelper
end
def can_modify_blob?(blob, project = @project, ref = @ref)
- !blob.lfs_pointer? && can_edit_tree?(project, ref)
+ !blob.valid_lfs_pointer? && can_edit_tree?(project, ref)
end
def leave_edit_message
@@ -114,28 +118,23 @@ module BlobHelper
icon("#{file_type_icon_class('file', mode, name)} fw")
end
- def blob_text_viewable?(blob)
- blob && blob.text? && !blob.lfs_pointer? && !blob.only_display_raw?
- end
-
- def blob_rendered_as_text?(blob)
- blob_text_viewable?(blob) && blob.to_partial_path(@project) == 'text'
- end
-
- def blob_size(blob)
- if blob.lfs_pointer?
- blob.lfs_size
- else
- blob.size
+ def blob_raw_url
+ if @snippet
+ if @snippet.project_id
+ raw_namespace_project_snippet_path(@project.namespace, @project, @snippet)
+ else
+ raw_snippet_path(@snippet)
+ end
+ elsif @blob
+ namespace_project_raw_path(@project.namespace, @project, @id)
end
end
# SVGs can contain malicious JavaScript; only include whitelisted
# elements and attributes. Note that this whitelist is by no means complete
# and may omit some elements.
- def sanitize_svg(blob)
- blob.data = Gitlab::Sanitizers::SVG.clean(blob.data)
- blob
+ def sanitize_svg_data(data)
+ Gitlab::Sanitizers::SVG.clean(data)
end
# If we blindly set the 'real' content type when serving a Git blob we
@@ -217,13 +216,52 @@ module BlobHelper
clipboard_button(text: file_path, gfm: "`#{file_path}`", class: 'btn-clipboard btn-transparent prepend-left-5', title: 'Copy file path to clipboard')
end
- def copy_blob_content_button(blob)
- return if markup?(blob.name)
+ def copy_blob_source_button(blob)
+ return unless blob.rendered_as_text?(ignore_errors: false)
+
+ clipboard_button(target: ".blob-content[data-blob-id='#{blob.id}']", class: "btn btn-sm js-copy-blob-source-btn", title: "Copy source to clipboard")
+ end
+
+ def open_raw_blob_button(blob)
+ if blob.raw_binary?
+ icon = icon('download')
+ title = 'Download'
+ else
+ icon = icon('file-code-o')
+ title = 'Open raw'
+ end
- clipboard_button(target: ".blob-content[data-blob-id='#{blob.id}']", class: "btn btn-sm", title: "Copy content to clipboard")
+ link_to icon, blob_raw_url, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' }
end
- def open_raw_file_button(path)
- link_to icon('file-code-o'), path, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: 'Open raw', data: { container: 'body' }
+ def blob_render_error_reason(viewer)
+ case viewer.render_error
+ when :too_large
+ max_size =
+ if viewer.absolutely_too_large?
+ viewer.absolute_max_size
+ elsif viewer.too_large?
+ viewer.max_size
+ end
+ "it is larger than #{number_to_human_size(max_size)}"
+ when :server_side_but_stored_in_lfs
+ "it is stored in LFS"
+ end
+ end
+
+ def blob_render_error_options(viewer)
+ options = []
+
+ if viewer.render_error == :too_large && viewer.can_override_max_size?
+ options << link_to('load it anyway', url_for(params.merge(viewer: viewer.type, override_max_size: true, format: nil)))
+ end
+
+ if viewer.rich? && viewer.blob.rendered_as_text?
+ options << link_to('view the source', '#', class: 'js-blob-viewer-switch-btn', data: { viewer: 'simple' })
+ end
+
+ options << link_to('download it', blob_raw_url, target: '_blank', rel: 'noopener noreferrer')
+
+ options
end
end
diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb
index 2de9e0de310..32b1e7822af 100644
--- a/app/helpers/ci_status_helper.rb
+++ b/app/helpers/ci_status_helper.rb
@@ -1,10 +1,16 @@
+##
+# DEPRECATED
+#
+# These helpers are deprecated in favor of detailed CI/CD statuses.
+#
+# See 'detailed_status?` method and `Gitlab::Ci::Status` module.
+#
module CiStatusHelper
def ci_status_path(pipeline)
project = pipeline.project
namespace_project_pipeline_path(project.namespace, project, pipeline)
end
- # Is used by Commit and Merge Request Widget
def ci_label_for_status(status)
if detailed_status?(status)
return status.label
@@ -22,6 +28,23 @@ module CiStatusHelper
end
end
+ def ci_text_for_status(status)
+ if detailed_status?(status)
+ return status.text
+ end
+
+ case status
+ when 'success'
+ 'passed'
+ when 'success_with_warnings'
+ 'passed'
+ when 'manual'
+ 'blocked'
+ else
+ status
+ end
+ end
+
def ci_status_for_statuseable(subject)
status = subject.try(:status) || 'not found'
status.humanize
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb
index 5f5c76d3722..960111ca045 100644
--- a/app/helpers/events_helper.rb
+++ b/app/helpers/events_helper.rb
@@ -10,11 +10,12 @@ module EventsHelper
'deleted' => 'icon_trash_o'
}.freeze
- def link_to_author(event)
+ def link_to_author(event, self_added: false)
author = event.author
if author
- link_to author.name, user_path(author.username), title: author.name
+ name = self_added ? 'You' : author.name
+ link_to name, user_path(author.username), title: name
else
event.author_name
end
diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb
index ab3ef454e1c..55fa81e95ef 100644
--- a/app/helpers/icons_helper.rb
+++ b/app/helpers/icons_helper.rb
@@ -7,6 +7,11 @@ module IconsHelper
# font-awesome-rails gem, but should we ever use a different icon pack in the
# future we won't have to change hundreds of method calls.
def icon(names, options = {})
+ if (options.keys & %w[aria-hidden aria-label]).empty?
+ # Add `aria-hidden` if there are no aria's set
+ options['aria-hidden'] = true
+ end
+
options.include?(:base) ? fa_stacked_icon(names, options) : fa_icon(names, options)
end
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index ec57fec4f99..0b13dbf5f8d 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -165,11 +165,8 @@ module IssuablesHelper
html.html_safe
end
- def cached_assigned_issuables_count(assignee, issuable_type, state)
- cache_key = hexdigest(['assigned_issuables_count', assignee.id, issuable_type, state].join('-'))
- Rails.cache.fetch(cache_key, expires_in: 2.minutes) do
- assigned_issuables_count(assignee, issuable_type, state)
- end
+ def assigned_issuables_count(issuable_type)
+ current_user.public_send("assigned_open_#{issuable_type}_count")
end
def issuable_filter_params
@@ -192,10 +189,6 @@ module IssuablesHelper
private
- def assigned_issuables_count(assignee, issuable_type, state)
- assignee.public_send("assigned_#{issuable_type}").public_send(state).count
- end
-
def sidebar_gutter_collapsed?
cookies[:collapsed_gutter] == 'true'
end
diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/markup_helper.rb
index cd442237086..b241a14740b 100644
--- a/app/helpers/gitlab_markdown_helper.rb
+++ b/app/helpers/markup_helper.rb
@@ -1,6 +1,22 @@
require 'nokogiri'
-module GitlabMarkdownHelper
+module MarkupHelper
+ def plain?(filename)
+ Gitlab::MarkupHelper.plain?(filename)
+ end
+
+ def markup?(filename)
+ Gitlab::MarkupHelper.markup?(filename)
+ end
+
+ def gitlab_markdown?(filename)
+ Gitlab::MarkupHelper.gitlab_markdown?(filename)
+ end
+
+ def asciidoc?(filename)
+ Gitlab::MarkupHelper.asciidoc?(filename)
+ end
+
# Use this in places where you would normally use link_to(gfm(...), ...).
#
# It solves a problem occurring with nested links (i.e.
@@ -11,7 +27,7 @@ module GitlabMarkdownHelper
# explicitly produce the correct linking behavior (i.e.
# "<a>outer text </a><a>gfm ref</a><a> more outer text</a>").
def link_to_gfm(body, url, html_options = {})
- return "" if body.blank?
+ return '' if body.blank?
context = {
project: @project,
@@ -43,71 +59,73 @@ module GitlabMarkdownHelper
fragment.to_html.html_safe
end
+ # Return the first line of +text+, up to +max_chars+, after parsing the line
+ # as Markdown. HTML tags in the parsed output are not counted toward the
+ # +max_chars+ limit. If the length limit falls within a tag's contents, then
+ # the tag contents are truncated without removing the closing tag.
+ def first_line_in_markdown(text, max_chars = nil, options = {})
+ md = markdown(text, options).strip
+
+ truncate_visible(md, max_chars || md.length) if md.present?
+ end
+
def markdown(text, context = {})
- return "" unless text.present?
+ return '' unless text.present?
context[:project] ||= @project
-
- html = Banzai.render(text, context)
- banzai_postprocess(html, context)
+ html = markdown_unsafe(text, context)
+ prepare_for_rendering(html, context)
end
def markdown_field(object, field)
object = object.for_display if object.respond_to?(:for_display)
- return "" unless object.present?
+ return '' unless object.present?
html = Banzai.render_field(object, field)
- banzai_postprocess(html, object.banzai_render_context(field))
+ prepare_for_rendering(html, object.banzai_render_context(field))
end
- def asciidoc(text)
- Gitlab::Asciidoc.render(
- text,
- project: @project,
- current_user: (current_user if defined?(current_user)),
-
- # RelativeLinkFilter
- project_wiki: @project_wiki,
- requested_path: @path,
- ref: @ref,
- commit: @commit
- )
+ def markup(file_name, text, context = {})
+ context[:project] ||= @project
+ html = context.delete(:rendered) || markup_unsafe(file_name, text, context)
+ prepare_for_rendering(html, context)
end
- def other_markup(file_name, text)
- Gitlab::OtherMarkup.render(
- file_name,
- text,
- project: @project,
- current_user: (current_user if defined?(current_user)),
+ def render_wiki_content(wiki_page)
+ text = wiki_page.content
+ return '' unless text.present?
+
+ context = { pipeline: :wiki, project: @project, project_wiki: @project_wiki, page_slug: wiki_page.slug }
+
+ html =
+ case wiki_page.format
+ when :markdown
+ markdown_unsafe(text, context)
+ when :asciidoc
+ asciidoc_unsafe(text)
+ else
+ wiki_page.formatted_content.html_safe
+ end
- # RelativeLinkFilter
- project_wiki: @project_wiki,
- requested_path: @path,
- ref: @ref,
- commit: @commit
- )
+ prepare_for_rendering(html, context)
end
- # Return the first line of +text+, up to +max_chars+, after parsing the line
- # as Markdown. HTML tags in the parsed output are not counted toward the
- # +max_chars+ limit. If the length limit falls within a tag's contents, then
- # the tag contents are truncated without removing the closing tag.
- def first_line_in_markdown(text, max_chars = nil, options = {})
- md = markdown(text, options).strip
+ def markup_unsafe(file_name, text, context = {})
+ return '' unless text.present?
- truncate_visible(md, max_chars || md.length) if md.present?
- end
-
- def render_wiki_content(wiki_page)
- case wiki_page.format
- when :markdown
- markdown(wiki_page.content, pipeline: :wiki, project_wiki: @project_wiki, page_slug: wiki_page.slug)
- when :asciidoc
- asciidoc(wiki_page.content)
+ if gitlab_markdown?(file_name)
+ markdown_unsafe(text, context)
+ elsif asciidoc?(file_name)
+ asciidoc_unsafe(text)
+ elsif plain?(file_name)
+ content_tag :pre, class: 'plain-readme' do
+ text
+ end
else
- wiki_page.formatted_content.html_safe
+ other_markup_unsafe(file_name, text)
end
+ rescue RuntimeError
+ simple_format(text)
end
# Returns the text necessary to reference `entity` across projects
@@ -183,10 +201,10 @@ module GitlabMarkdownHelper
end
def markdown_toolbar_button(options = {})
- data = options[:data].merge({ container: "body" })
+ data = options[:data].merge({ container: 'body' })
content_tag :button,
- type: "button",
- class: "toolbar-btn js-md has-tooltip hidden-xs",
+ type: 'button',
+ class: 'toolbar-btn js-md has-tooltip hidden-xs',
tabindex: -1,
data: data,
title: options[:title],
@@ -195,17 +213,35 @@ module GitlabMarkdownHelper
end
end
- # Calls Banzai.post_process with some common context options
- def banzai_postprocess(html, context)
+ def markdown_unsafe(text, context = {})
+ Banzai.render(text, context)
+ end
+
+ def asciidoc_unsafe(text)
+ Gitlab::Asciidoc.render(text)
+ end
+
+ def other_markup_unsafe(file_name, text)
+ Gitlab::OtherMarkup.render(file_name, text)
+ end
+
+ def prepare_for_rendering(html, context = {})
+ return '' unless html.present?
+
context.merge!(
current_user: (current_user if defined?(current_user)),
# RelativeLinkFilter
- requested_path: @path,
+ commit: @commit,
project_wiki: @project_wiki,
- ref: @ref
+ ref: @ref,
+ requested_path: @path
)
- Banzai.post_process(html, context)
+ html = Banzai.post_process(html, context)
+
+ Hamlit::RailsHelpers.preserve(html)
end
+
+ extend self
end
diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb
index 38be073c8dc..2614cdfe90e 100644
--- a/app/helpers/merge_requests_helper.rb
+++ b/app/helpers/merge_requests_helper.rb
@@ -1,6 +1,6 @@
module MergeRequestsHelper
def new_mr_path_from_push_event(event)
- target_project = event.project.forked_from_project || event.project
+ target_project = event.project.default_merge_request_target
new_namespace_project_merge_request_path(
event.project.namespace,
event.project,
@@ -56,11 +56,12 @@ module MergeRequestsHelper
end
def issues_sentence(issues)
- # Sorting based on the `#123` or `group/project#123` reference will sort
- # local issues first.
- issues.map do |issue|
+ # Issuable sorter will sort local issues, then issues from the same
+ # namespace, then all other issues.
+ issues = Gitlab::IssuableSorter.sort(@project, issues).map do |issue|
issue.to_reference(@project)
- end.sort.to_sentence
+ end
+ issues.to_sentence
end
def mr_closes_issues
@@ -126,6 +127,10 @@ module MergeRequestsHelper
end
end
+ def target_projects(project)
+ [project, project.default_merge_request_target].uniq
+ end
+
def merge_request_button_visibility(merge_request, closed)
return 'hidden' if merge_request.closed? == closed || (merge_request.merged? == closed && !merge_request.closed?) || merge_request.closed_without_fork?
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 5f97e6114ea..8c26348a975 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -160,12 +160,17 @@ module ProjectsHelper
end
def project_list_cache_key(project)
- key = [project.namespace.cache_key, project.cache_key, controller.controller_name, controller.action_name, current_application_settings.cache_key, 'v2.3']
+ key = [project.namespace.cache_key, project.cache_key, controller.controller_name, controller.action_name, current_application_settings.cache_key, 'v2.4']
key << pipeline_status_cache_key(project.pipeline_status) if project.pipeline_status.has_status?
key
end
+ def load_pipeline_status(projects)
+ Gitlab::Cache::Ci::ProjectPipelineStatus.
+ load_in_batch_for_projects(projects)
+ end
+
private
def repo_children_classes(field)
diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb
index 715e5893a2c..3707bb5ba36 100644
--- a/app/helpers/services_helper.rb
+++ b/app/helpers/services_helper.rb
@@ -13,8 +13,8 @@ module ServicesHelper
"Event will be triggered when a confidential issue is created/updated/closed"
when "merge_request", "merge_request_events"
"Event will be triggered when a merge request is created/updated/merged"
- when "build", "build_events"
- "Event will be triggered when a build status changes"
+ when "pipeline", "pipeline_events"
+ "Event will be triggered when a pipeline status changes"
when "wiki_page", "wiki_page_events"
"Event will be triggered when a wiki page is created/updated"
when "commit", "commit_events"
diff --git a/app/helpers/snippets_helper.rb b/app/helpers/snippets_helper.rb
index 979264c9421..2fd64b3441e 100644
--- a/app/helpers/snippets_helper.rb
+++ b/app/helpers/snippets_helper.rb
@@ -8,6 +8,14 @@ module SnippetsHelper
end
end
+ def download_snippet_path(snippet)
+ if snippet.project_id
+ raw_namespace_project_snippet_path(@project.namespace, @project, snippet, inline: false)
+ else
+ raw_snippet_path(snippet, inline: false)
+ end
+ end
+
# Return the path of a snippets index for a user or for a project
#
# @returns String, path to snippet index
diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb
index fb95f2b565e..a762b320d56 100644
--- a/app/helpers/submodule_helper.rb
+++ b/app/helpers/submodule_helper.rb
@@ -5,7 +5,7 @@ module SubmoduleHelper
def submodule_links(submodule_item, ref = nil, repository = @repository)
url = repository.submodule_url_for(ref, submodule_item.path)
- return url, nil unless url =~ /([^\/:]+)\/([^\/]+\.git)\Z/
+ return url, nil unless url =~ /([^\/:]+)\/([^\/]+(?:\.git)?)\Z/
namespace = $1
project = $2
@@ -37,14 +37,16 @@ module SubmoduleHelper
end
def self_url?(url, namespace, project)
- return true if url == [Gitlab.config.gitlab.url, '/', namespace, '/',
- project, '.git'].join('')
- url == gitlab_shell.url_to_repo([namespace, '/', project].join(''))
+ url_no_dotgit = url.chomp('.git')
+ return true if url_no_dotgit == [Gitlab.config.gitlab.url, '/', namespace, '/',
+ project].join('')
+ url_with_dotgit = url_no_dotgit + '.git'
+ url_with_dotgit == gitlab_shell.url_to_repo([namespace, '/', project].join(''))
end
def relative_self_url?(url)
# (./)?(../repo.git) || (./)?(../../project/repo.git) )
- url =~ /\A((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*\.git\z/ || url =~ /\A((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*\.git\z/
+ url =~ /\A((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*(\.git)?\z/ || url =~ /\A((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*(\.git)?\z/
end
def standard_links(host, namespace, project, commit)
diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb
index 4f5adf623f2..f19e2f9db9c 100644
--- a/app/helpers/todos_helper.rb
+++ b/app/helpers/todos_helper.rb
@@ -13,13 +13,13 @@ module TodosHelper
def todo_action_name(todo)
case todo.action
- when Todo::ASSIGNED then 'assigned you'
- when Todo::MENTIONED then 'mentioned you on'
+ when Todo::ASSIGNED then todo.self_added? ? 'assigned' : 'assigned you'
+ when Todo::MENTIONED then "mentioned #{todo_action_subject(todo)} on"
when Todo::BUILD_FAILED then 'The build failed for'
when Todo::MARKED then 'added a todo for'
- when Todo::APPROVAL_REQUIRED then 'set you as an approver for'
+ when Todo::APPROVAL_REQUIRED then "set #{todo_action_subject(todo)} as an approver for"
when Todo::UNMERGEABLE then 'Could not merge'
- when Todo::DIRECTLY_ADDRESSED then 'directly addressed you on'
+ when Todo::DIRECTLY_ADDRESSED then "directly addressed #{todo_action_subject(todo)} on"
end
end
@@ -148,6 +148,10 @@ module TodosHelper
private
+ def todo_action_subject(todo)
+ todo.self_added? ? 'yourself' : 'you'
+ end
+
def show_todo_state?(todo)
(todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && %w(closed merged).include?(todo.target.state)
end
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index f1dab60524e..f7b5a5f4dfc 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -12,10 +12,6 @@ module TreeHelper
tree.html_safe
end
- def render_readme(readme)
- render_markup(readme.name, readme.data)
- end
-
# Return an image icon depending on the file type and mode
#
# type - String type of the tree item; either 'folder' or 'file'