aboutsummaryrefslogtreecommitdiff
path: root/receivepack/service/command.go
blob: 33342e4139f1e7968d1e128ace3213d973d1f9f0 (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
package service

import "codeberg.org/lindenii/furgit/objectid"

// Command is one protocol-independent requested ref update.
type Command struct {
	OldID objectid.ObjectID
	NewID objectid.ObjectID
	Name  string
}

func fillCommandErrors(result *Result, commands []Command, errText string) {
	for _, command := range commands {
		result.Commands = append(result.Commands, CommandResult{
			Name:    command.Name,
			Error:   errText,
			RefName: command.Name,
			OldID:   objectIDPointer(command.OldID),
			NewID:   objectIDPointer(command.NewID),
		})
	}
}

func isDelete(command Command) bool {
	return command.NewID == objectid.Zero(command.NewID.Algorithm())
}

func objectIDPointer(id objectid.ObjectID) *objectid.ObjectID {
	out := id

	return &out
}