Skip to content

Be more specific what directories to traverse when using find

Achilleas Pipinellis requested to merge normalize-script into master

scripts/normalize-links.sh is used to replace the URLs for a given version by prefixing any relative URL (href="/index.html") with the versioned one (href="/13.0/index.html").

I was trying to replicate #759 (closed) locally, and I encountered a bug in the script that replaces the URLs for the versions.

Given the following tree directory:

public
├── 12.10
├── 12.9
├── 13.0
├── 404.html
├── _data
├── archives
├── assets
├── cookies-policy
├── favicon.ico
├── frontend
├── index.html
├── opensearch.xml
├── robots.txt
├── runner
├── search
└── sitemap.xml

If I wanted to replace the 13.0 URLs, I'd do:

./scripts/normalize-links.sh public 13.0

And the script would use find public/ ... which would include ALL files under public/, not just the version I wanted.

This MR fixes it and the script will now use find public/13.0 ... which is more explicit.

PS. It wasn't an issue with the Docker images so far, because there is only one version in the directory where find is run, so the script ran successfully https://gitlab.com/gitlab-org/gitlab-docs/-/blob/2a755f08749d292d4b69f9e7f4830735a428d909/dockerfiles/Dockerfile.builder.onbuild#L26. It shouldn't change anything.

Edited by Achilleas Pipinellis

Merge request reports