Skip to content

Pass --strip-component when running tar -zxf to unwrap archive

Lin Jen-Shin requested to merge 386501-tar-strip-component into master

What does this MR do and why?

Pass --strip-component when running tar -zxf to unwrap archive.

When we download the archive with:

curl --location --output "jh.tar.gz" --get --data-urlencode "sha=vs/upgrade-sprockets-jh" --data-urlencode "path=jh" "https://gitlab.com/api/v4/projects/33019816/repository/archive"

The wrapping directory inside the archive is called gitlab-vs-upgrade-sprockets-jh-a5ca7ea3205219c78eb2d59d339bd71622b08853-jh. This is unexpected to the previous implementation, which assumes that the name should contain the ref name, which is vs/upgrade-sprockets-jh. However, using / as part of the filename is clearly problematic and it's changed to - in the archive, thus gitlab-vs-upgrade-sprockets-jh, but then it did not match the expectation and then the follow up mv failed due to filename mismatch.

If we pass --strip-component when tar -zxf, we unwrap that directory then we don't need to worry about the filename anymore.

How to validate

It's working for main-jh: https://gitlab.com/gitlab-org/gitlab/-/jobs/3512203520

Should also work for any name, because we don't specify at all.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #386501 (closed)

Edited by Lin Jen-Shin

Merge request reports