aboutsummaryrefslogtreecommitdiff
path: root/object/signed/commit/commit.go
blob: f3e0a0212171baebf7fee4e5f57175fd61f97d33 (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
package commit

import "lindenii.org/go/furgit/object/id"

// Commit represents the payload and signatures
// parsed from a raw commit object.
type Commit struct {
	body       []byte
	payload    []byteRange
	signatures map[id.ObjectFormat][]byteRange
}

// ObjectFormats returns the object formats
// for which the commit carries signatures.
func (commit *Commit) ObjectFormats() []id.ObjectFormat {
	var objectFormats []id.ObjectFormat

	for _, objectFormat := range id.SupportedObjectFormats() {
		if _, ok := commit.signatures[objectFormat]; ok {
			objectFormats = append(objectFormats, objectFormat)
		}
	}

	return objectFormats
}

type byteRange struct {
	start int
	end   int
}