aboutsummaryrefslogtreecommitdiff
path: root/receivepack/translate.go
blob: ee61b683ce97d246a40303809afde01ba92cee1b (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
}