shithub: furgit

ref: 1556cfb51d980ae8c5bf664ad69f3abd46f02386
dir: /receivepack/service/command.go/

View raw version
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
}