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
|
package signature
import (
"slices"
"strconv"
)
// AppendTo renders the signature in canonical Git format.
func (signature Signature) AppendTo(dst []byte) []byte {
dst = slices.Grow(dst, len(signature.Name)+len(signature.Email)+32)
dst = append(dst, signature.Name...)
dst = append(dst, ' ', '<')
dst = append(dst, signature.Email...)
dst = append(dst, '>', ' ')
dst = strconv.AppendInt(dst, signature.WhenUnix, 10)
dst = append(dst, ' ')
offset := signature.OffsetMinutes
var sign byte = '+'
if offset < 0 {
sign = '-'
offset = -offset
}
hh := offset / 60
mm := offset % 60
dst = append(dst, sign)
dst = append(dst, byte('0'+hh/10), byte('0'+hh%10))
dst = append(dst, byte('0'+mm/10), byte('0'+mm%10))
return dst
}
|