diff options
| author | 2026-03-07 14:24:32 +0800 | |
|---|---|---|
| committer | 2026-03-07 17:21:05 +0800 | |
| commit | 175c8ed3c342f34110cdca42dc4027050b39d7fb (patch) | |
| tree | 8e0ddddc5b7146816f859c2013c7fb7909807e03 /receivepack/version.go | |
| parent | receivepack: Add service semantics thingy (diff) | |
| signature | No signature | |
receivepack: Connect protocol with service v0.1.72
Diffstat (limited to 'receivepack/version.go')
| -rw-r--r-- | receivepack/version.go | 35 |
1 files changed, 35 insertions, 0 deletions
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 +} |
