diff --git a/internal/gitaly/service/repository/backup_custom_hooks.go b/internal/gitaly/service/repository/backup_custom_hooks.go index f47fcb81d15cb9bd37107e7a0ae4f0652a335023..9853848c7136d7b0a78a16553ac9e20403625b83 100644 --- a/internal/gitaly/service/repository/backup_custom_hooks.go +++ b/internal/gitaly/service/repository/backup_custom_hooks.go @@ -3,6 +3,7 @@ package repository import ( "os" "path/filepath" + "runtime" "gitlab.com/gitlab-org/gitaly/v15/internal/command" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/service" @@ -33,7 +34,13 @@ func (s *server) BackupCustomHooks(in *gitalypb.BackupCustomHooksRequest, stream } ctx := stream.Context() - tar := []string{"tar", "-c", "-f", "-", "-C", repoPath, customHooksDir} + + var tar []string + if runtime.GOOS == "darwin" { + tar = []string{"tar", "--no-mac-metadata", "-c", "-f", "-", "-C", repoPath, customHooksDir} + } else { + tar = []string{"tar", "-c", "-f", "-", "-C", repoPath, customHooksDir} + } cmd, err := command.New(ctx, tar, command.WithStdout(writer)) if err != nil { return status.Errorf(codes.Internal, "%v", err) diff --git a/internal/gitaly/service/repository/create_repository_from_snapshot_test.go b/internal/gitaly/service/repository/create_repository_from_snapshot_test.go index b082a242bb5106d3b0000d58cfc385bf4cf43ef6..340090ebc4ac5df94834ed8710eb5ea474b38e71 100644 --- a/internal/gitaly/service/repository/create_repository_from_snapshot_test.go +++ b/internal/gitaly/service/repository/create_repository_from_snapshot_test.go @@ -11,6 +11,7 @@ import ( "net/url" "os" "path/filepath" + "runtime" "strings" "testing" @@ -62,7 +63,12 @@ func (h *tarTesthandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Create a tar file for the repo in memory, without relying on TarBuilder func generateTarFile(t *testing.T, path string) ([]byte, []string) { - data := testhelper.MustRunCommand(t, nil, "tar", "-C", path, "-cf", "-", ".") + var data []byte + if runtime.GOOS == "darwin" { + data = testhelper.MustRunCommand(t, nil, "tar", "-C", path, "--no-mac-metadata", "-cf", "-", ".") + } else { + data = testhelper.MustRunCommand(t, nil, "tar", "-C", path, "-cf", "-", ".") + } entries, err := archive.TarEntries(bytes.NewReader(data)) require.NoError(t, err)