diff --git a/repository/repository.go b/repository/repository.go index dac0cfa2..dc55949e 100644 --- a/repository/repository.go +++ b/repository/repository.go @@ -143,6 +143,14 @@ func (r *Repository) ensureFork(ctx context.Context) error { os.RemoveAll(r.forkRepoPath) return err } + // Enable push options support so that pushes from user repos with + // push.pushOption configured (or git versions that send push options + // by default) don't fail with "the receiving end does not support + // push options". See https://github.com/dagger/container-use/issues/323 + if _, err := RunGitCommand(ctx, r.forkRepoPath, "config", "receive.advertisePushOptions", "true"); err != nil { + os.RemoveAll(r.forkRepoPath) + return err + } return nil }) } diff --git a/repository/repository_test.go b/repository/repository_test.go index 2d2924b4..5f30ebef 100644 --- a/repository/repository_test.go +++ b/repository/repository_test.go @@ -64,5 +64,10 @@ func TestRepositoryOpen(t *testing.T) { remote, err := RunGitCommand(ctx, tempDir, "remote", "get-url", "container-use") require.NoError(t, err) assert.Equal(t, repo.forkRepoPath, strings.TrimSpace(remote)) + + // Verify push options are enabled on the fork repo (issue #323) + pushOpts, err := RunGitCommand(ctx, repo.forkRepoPath, "config", "receive.advertisePushOptions") + require.NoError(t, err) + assert.Equal(t, "true", strings.TrimSpace(pushOpts)) }) }