e4a47c5f75dd4df97652e7c11429694a9bf62b7b

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat: support git push options (#341)

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

Diff

 1diff --git a/server/git/service.go b/server/git/service.go
 2index b5b0f6af402cf525fc31abcaee3416edbb10fc55..b2cd6aa26b294a95d38d072e45054358be56bacd 100644
 3--- a/server/git/service.go
 4+++ b/server/git/service.go
 5@@ -50,8 +50,15 @@ type ServiceHandler func(ctx context.Context, cmd ServiceCommand) error
 6 
 7 // gitServiceHandler is the default service handler using the git binary.
 8 func gitServiceHandler(ctx context.Context, svc Service, scmd ServiceCommand) error {
 9-	cmd := exec.CommandContext(ctx, "git", "-c", "uploadpack.allowFilter=true", svc.Name()) // nolint: gosec
10+	cmd := exec.CommandContext(ctx, "git")
11 	cmd.Dir = scmd.Dir
12+	cmd.Args = append(cmd.Args, []string{
13+		// Enable partial clones
14+		"-c", "uploadpack.allowFilter=true",
15+		// Enable push options
16+		"-c", "receive.advertisePushOptions=true",
17+		svc.Name(),
18+	}...)
19 	if len(scmd.Args) > 0 {
20 		cmd.Args = append(cmd.Args, scmd.Args...)
21 	}