Skip to content

Add docs redirect raketask

What does this MR do?

Automate the process defined under https://docs.gitlab.com/ee/development/documentation/#move-or-rename-a-page

Given two arguments, oldpath and newpath, replaces the contents of oldpath with the following template:

---
redirect_to: 'newpath'
---

This document was moved to [another location](newpath).

<!-- This redirect file can be deleted after <YYYY-MM-DD>. -->
<!-- Before deletion, see: https://docs.gitlab.com/ee/development/documentation/#move-or-rename-a-page -->
  • Since we're removing redirects older than 3 months or 1 year (relative and external URLs respectively), add a check to add the date YYYY-MM-DD automatically.
  • Given both paths are relative, calculate the relative path between them.
  • Given the new path is an external URL, use that in the template.
  • Redirecting to anchored URLs works.
  • If the old path doesn't exist, the Rake task fails.

Real example to test:

cp doc/integration/azure.md doc/administration/auth/azure.md
bin/rake "gitlab:docs:redirect[doc/integration/azure.md,doc/administration/auth/azure.md]"

Does this MR meet the acceptance criteria?

Conformity

Edited by Achilleas Pipinellis

Merge request reports

Loading