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

redirects_for_missing_path_on_tree.rb « concerns « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 97c23a2cf3c80cff66b9bae03289ce5b0057e381 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

module RedirectsForMissingPathOnTree
  def redirect_to_tree_root_for_missing_path(project, ref, path, ref_type: nil)
    redirect_to project_tree_path(project, ref, ref_type: ref_type), notice: missing_path_on_ref(path, ref)
  end

  private

  def missing_path_on_ref(path, ref)
    format(_('"%{path}" did not exist on "%{ref}"'), path: truncate_path(path), ref: ref)
  end

  def truncate_path(path)
    path.reverse.truncate(60, separator: "/").reverse
  end
end