aboutsummaryrefslogtreecommitdiff
path: root/object/signed/commit/signature.go
blob: 4dc47be5677efe9b987d099c2338b5f5c546b7cd (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package commit

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

// AppendSignature appends the unfolded signature for objectFormat to dst,
// and reports whether the commit carries a signature for objectFormat.
func (commit *Commit) AppendSignature(dst []byte, objectFormat id.ObjectFormat) ([]byte, bool) {
	signature, ok := commit.signatures[objectFormat]
	if !ok {
		return dst, false
	}

	for _, part := range signature {
		dst = append(dst, commit.body[part.start:part.end]...)
	}

	return dst, true
}