feat: support git push options (#341)

Ayman Bagabas created

Add support to git push options.

Reference: https://git-scm.com/docs/git-push#Documentation/git-push.txt--oltoptiongt
Fixes: https://github.com/charmbracelet/soft-serve/issues/327

Change summary

server/git/service.go | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

Detailed changes

server/git/service.go 🔗

@@ -50,8 +50,15 @@ type ServiceHandler func(ctx context.Context, cmd ServiceCommand) error
 
 // gitServiceHandler is the default service handler using the git binary.
 func gitServiceHandler(ctx context.Context, svc Service, scmd ServiceCommand) error {
-	cmd := exec.CommandContext(ctx, "git", "-c", "uploadpack.allowFilter=true", svc.Name()) // nolint: gosec
+	cmd := exec.CommandContext(ctx, "git")
 	cmd.Dir = scmd.Dir
+	cmd.Args = append(cmd.Args, []string{
+		// Enable partial clones
+		"-c", "uploadpack.allowFilter=true",
+		// Enable push options
+		"-c", "receive.advertisePushOptions=true",
+		svc.Name(),
+	}...)
 	if len(scmd.Args) > 0 {
 		cmd.Args = append(cmd.Args, scmd.Args...)
 	}