chore: protocol v2

Signed-off-by: jolheiser <john.olheiser@gmail.com>
ffdhall
jolheiser 2024-02-22 15:04:08 -06:00
parent ba6ffd62ec
commit a56081be17
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
1 changed files with 4 additions and 2 deletions

View File

@ -27,7 +27,7 @@ func (c CmdProtocol) HTTPInfoRefs(ctx ReadWriteContexter) error {
if err := pkt.Flush(); err != nil { if err := pkt.Flush(); err != nil {
return err return err
} }
return gitService(ctx, "receive-pack", string(c), "--stateless-rpc", "--advertise-refs") return gitService(ctx, "upload-pack", string(c), "--stateless-rpc", "--advertise-refs")
} }
func (c CmdProtocol) HTTPUploadPack(ctx ReadWriteContexter) error { func (c CmdProtocol) HTTPUploadPack(ctx ReadWriteContexter) error {
@ -45,6 +45,7 @@ func (c CmdProtocol) SSHReceivePack(ctx ReadWriteContexter, _ *Repo) error {
func gitService(ctx ReadWriteContexter, command, repoDir string, args ...string) error { func gitService(ctx ReadWriteContexter, command, repoDir string, args ...string) error {
cmd := exec.CommandContext(ctx.Context(), "git") cmd := exec.CommandContext(ctx.Context(), "git")
cmd.Args = append(cmd.Args, []string{ cmd.Args = append(cmd.Args, []string{
"-c", "protocol.version=2",
"-c", "uploadpack.allowFilter=true", "-c", "uploadpack.allowFilter=true",
"-c", "receive.advertisePushOptions=true", "-c", "receive.advertisePushOptions=true",
"-c", fmt.Sprintf("core.hooksPath=%s", filepath.Join(filepath.Dir(repoDir), "hooks")), "-c", fmt.Sprintf("core.hooksPath=%s", filepath.Join(filepath.Dir(repoDir), "hooks")),
@ -54,9 +55,10 @@ func gitService(ctx ReadWriteContexter, command, repoDir string, args ...string)
cmd.Args = append(cmd.Args, args...) cmd.Args = append(cmd.Args, args...)
} }
cmd.Args = append(cmd.Args, repoDir) cmd.Args = append(cmd.Args, repoDir)
cmd.Env = append(os.Environ(), fmt.Sprintf("UGIT_REPODIR=%s", repoDir)) cmd.Env = append(os.Environ(), fmt.Sprintf("UGIT_REPODIR=%s", repoDir), "GIT_PROTOCOL=version=2")
cmd.Stdin = ctx cmd.Stdin = ctx
cmd.Stdout = ctx cmd.Stdout = ctx
fmt.Println(cmd.Env, cmd.String())
return cmd.Run() return cmd.Run()
} }