blob: 0afff5e05b3a70d3a3bc4d686bf327764087d23b (
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
33
|
package signature
import (
"fmt"
"strconv"
"strings"
)
// Bytes renders the signature in canonical Git format.
func (signature Signature) Bytes() ([]byte, error) {
var b strings.Builder
b.Grow(len(signature.Name) + len(signature.Email) + 32)
b.Write(signature.Name)
b.WriteString(" <")
b.Write(signature.Email)
b.WriteString("> ")
b.WriteString(strconv.FormatInt(signature.WhenUnix, 10))
b.WriteByte(' ')
offset := signature.OffsetMinutes
sign := '+'
if offset < 0 {
sign = '-'
offset = -offset
}
hh := offset / 60
mm := offset % 60
fmt.Fprintf(&b, "%c%02d%02d", sign, hh, mm)
return []byte(b.String()), nil
}
|