Skip to content

repository: Suppress macOS metadata in tar archive

By default macOS's bsdtar(1) will include ._ resource fork files in the archive, unless the --no-mac-metadata flag is passed on archive creation. These files are suppressed during extraction by default, but in several tests we are directly reading the archive and finding files we won't see in a Linux environment.

Specifically, tests like TestCreateRepositoryFromSnapshot_success and TestBackupCustomHooks_symlink are running into this scenario and will fail with errors like:

file "._." not unpacked

and:

[]string{"custom_hooks/pre-commit.sample"} does not contain "._custom_hooks"

To resolve this, pass the --no-mac-metadata flag to tar in BackupCustomHooks and generateTarFile to ensure we get clean archives.

Note: the man page for BSD tar states the --no-mac-metadata flag is specific to x mode, but testing shows that it works in c mode as well.

Edited by Will Chandler (ex-GitLab)

Merge request reports

Loading