export Trailer struct fields

This commit is contained in:
Jesse Hathaway 2020-06-02 14:46:00 +00:00
parent 0e26174be2
commit ca080d554e
2 changed files with 6 additions and 6 deletions

View File

@ -11,8 +11,8 @@ import (
// Trailer represents a single git message trailer.
type Trailer struct {
key string
value string
Key string
Value string
}
// MessageTrailers parses trailers out of a message, returning a slice of
@ -37,7 +37,7 @@ func MessageTrailers(message string) ([]Trailer, error) {
var trailer *C.git_message_trailer
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); p += unsafe.Sizeof(C.git_message_trailer{}) {
trailer = (*C.git_message_trailer)(unsafe.Pointer(p))
trailers[i] = Trailer{key: C.GoString(trailer.key), value: C.GoString(trailer.value)}
trailers[i] = Trailer{Key: C.GoString(trailer.key), Value: C.GoString(trailer.value)}
i++
}
return trailers, nil

View File

@ -19,14 +19,14 @@ func TestTrailers(t *testing.T) {
{
"commit with one trailer\n\nCo-authored-by: Alice <alice@example.com>\n",
[]Trailer{
Trailer{key: "Co-authored-by", value: "Alice <alice@example.com>"},
Trailer{Key: "Co-authored-by", Value: "Alice <alice@example.com>"},
},
},
{
"commit with two trailers\n\nCo-authored-by: Alice <alice@example.com>\nSigned-off-by: Bob <bob@example.com>\n",
[]Trailer{
Trailer{key: "Co-authored-by", value: "Alice <alice@example.com>"},
Trailer{key: "Signed-off-by", value: "Bob <bob@example.com>"}},
Trailer{Key: "Co-authored-by", Value: "Alice <alice@example.com>"},
Trailer{Key: "Signed-off-by", Value: "Bob <bob@example.com>"}},
},
}
for _, test := range tests {