aboutsummaryrefslogtreecommitdiff
path: root/receivepack/translate.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-07 14:24:32 +0800
committerGravatar Runxi Yu2026-03-07 17:21:05 +0800
commit175c8ed3c342f34110cdca42dc4027050b39d7fb (patch)
tree8e0ddddc5b7146816f859c2013c7fb7909807e03 /receivepack/translate.go
parentreceivepack: Add service semantics thingy (diff)
signatureNo signature
receivepack: Connect protocol with service v0.1.72
Diffstat (limited to 'receivepack/translate.go')
-rw-r--r--receivepack/translate.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/receivepack/translate.go b/receivepack/translate.go
new file mode 100644
index 00000000..ee61b683
--- /dev/null
+++ b/receivepack/translate.go
@@ -0,0 +1,35 @@
+package receivepack
+
+import (
+ protoreceive "codeberg.org/lindenii/furgit/protocol/v0v1/server/receivepack"
+ "codeberg.org/lindenii/furgit/receivepack/internal/service"
+)
+
+func translateCommands(commands []protoreceive.Command) []service.Command {
+ out := make([]service.Command, 0, len(commands))
+ for _, command := range commands {
+ out = append(out, service.Command{
+ OldID: command.OldID,
+ NewID: command.NewID,
+ Name: command.Name,
+ })
+ }
+
+ return out
+}
+
+func translateResult(result *service.Result) protoreceive.ReportStatusResult {
+ out := protoreceive.ReportStatusResult{
+ UnpackError: result.UnpackError,
+ Commands: make([]protoreceive.CommandResult, 0, len(result.Commands)),
+ }
+
+ for _, command := range result.Commands {
+ out.Commands = append(out.Commands, protoreceive.CommandResult{
+ Name: command.Name,
+ Error: command.Error,
+ })
+ }
+
+ return out
+}