From 175c8ed3c342f34110cdca42dc4027050b39d7fb Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 7 Mar 2026 14:24:32 +0800 Subject: receivepack: Connect protocol with service --- receivepack/version.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 receivepack/version.go (limited to 'receivepack/version.go') diff --git a/receivepack/version.go b/receivepack/version.go new file mode 100644 index 00000000..42c5b38b --- /dev/null +++ b/receivepack/version.go @@ -0,0 +1,35 @@ +package receivepack + +import ( + "strings" + + common "codeberg.org/lindenii/furgit/protocol/v0v1/server" +) + +func parseVersion(gitProtocol string) common.Version { + if gitProtocol == "" { + return common.Version0 + } + + var highestRequested uint8 + + for field := range strings.SplitSeq(gitProtocol, ":") { + switch field { + case "version=0": + case "version=1": + if highestRequested < 1 { + highestRequested = 1 + } + case "version=2": + if highestRequested < 2 { + highestRequested = 2 + } + } + } + + if highestRequested == 1 { + return common.Version1 + } + + return common.Version0 +} -- cgit v1.3.1-10-gc9f91