diff options
author | karthik nayak <knayak@gitlab.com> | 2023-11-06 12:22:29 +0300 |
---|---|---|
committer | karthik nayak <knayak@gitlab.com> | 2023-11-06 12:22:29 +0300 |
commit | 5b926ece522daf2fadc6a9817ece0d594a8b7394 (patch) | |
tree | cb6bdba4e38aee038057e42684e6dc536dc285e1 | |
parent | 9bf28d2089501b82b40e2b9f6ad21cf80751f15f (diff) | |
parent | d0310a0e359bbca440288a4d14aec4ea9796389e (diff) |
Merge branch 'xx/add-support-for-protocol-version-1' into 'master'
protocol: Add support for git protocol version 1
See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/6504
Merged-by: karthik nayak <knayak@gitlab.com>
Approved-by: karthik nayak <knayak@gitlab.com>
Reviewed-by: Patrick Steinhardt <psteinhardt@gitlab.com>
Reviewed-by: karthik nayak <knayak@gitlab.com>
Co-authored-by: Xing Xin <xingxin.xx@bytedance.com>
-rw-r--r-- | internal/git/protocol.go | 5 | ||||
-rw-r--r-- | internal/git/protocol_test.go | 18 | ||||
-rw-r--r-- | internal/gitaly/service/smarthttp/inforefs.go | 2 |
3 files changed, 20 insertions, 5 deletions
diff --git a/internal/git/protocol.go b/internal/git/protocol.go index 72011ecf7..6979c59b1 100644 --- a/internal/git/protocol.go +++ b/internal/git/protocol.go @@ -12,6 +12,8 @@ import ( ) const ( + // ProtocolV1 is the special value used by Git clients to request protocol v1 + ProtocolV1 = "version=1" // ProtocolV2 is the special value used by Git clients to request protocol v2 ProtocolV2 = "version=2" ) @@ -46,6 +48,9 @@ func gitProtocolEnv(ctx context.Context, logger log.Logger, req RequestWithGitPr case ProtocolV2: env = append(env, fmt.Sprintf("GIT_PROTOCOL=%s", ProtocolV2)) protocol = "v2" + case ProtocolV1: + env = append(env, fmt.Sprintf("GIT_PROTOCOL=%s", ProtocolV1)) + protocol = "v1" case "": protocol = "v0" default: diff --git a/internal/git/protocol_test.go b/internal/git/protocol_test.go index 7c233f88f..8c92bb657 100644 --- a/internal/git/protocol_test.go +++ b/internal/git/protocol_test.go @@ -22,14 +22,24 @@ func TestGitProtocolEnv(t *testing.T) { env []string }{ { - desc: "no V2 request", - env: nil, - }, - { desc: "V2 request", msg: fakeProtocolMessage{protocol: "version=2"}, env: []string{"GIT_PROTOCOL=version=2"}, }, + { + desc: "V1 request", + msg: fakeProtocolMessage{protocol: "version=1"}, + env: []string{"GIT_PROTOCOL=version=1"}, + }, + { + desc: "Invalid version in request", + msg: fakeProtocolMessage{protocol: "version=invalid"}, + env: nil, + }, + { + desc: "No version in request", + env: nil, + }, } { t.Run(tt.desc, func(t *testing.T) { ctx := testhelper.Context(t) diff --git a/internal/gitaly/service/smarthttp/inforefs.go b/internal/gitaly/service/smarthttp/inforefs.go index 792c6e7d4..2a01868d7 100644 --- a/internal/gitaly/service/smarthttp/inforefs.go +++ b/internal/gitaly/service/smarthttp/inforefs.go @@ -59,7 +59,7 @@ func (s *server) handleInfoRefs(ctx context.Context, service, repoPath string, r cmdOpts := []git.CmdOpt{git.WithGitProtocol(s.logger, req), git.WithStdout(w)} if service == "receive-pack" { - cmdOpts = append(cmdOpts, git.WithRefTxHook(req.Repository)) + cmdOpts = append(cmdOpts, git.WithDisabledHooks()) } config, err := git.ConvertConfigOptions(req.GitConfigOptions) |