Add support for parsing git trailers #614
|
@ -11,8 +11,8 @@ import (
|
||||||
|
|||||||
|
|
||||||
// Trailer represents a single git message trailer.
|
// Trailer represents a single git message trailer.
|
||||||
type Trailer struct {
|
type Trailer struct {
|
||||||
key string
|
Key string
|
||||||
![]() minor nit:
(if this was copied from another file, let me know which one and we'll fix that later). minor nit:
```suggestion
```
(if this was copied from another file, let me know which one and we'll fix that later).
![]() maybe
for a tiny bit more symmetry between the initialization and post-steps. maybe
```suggestion
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); i, p = i + 1, p + unsafe.Sizeof(C.git_message_trailer{}) {
```
for a tiny bit more symmetry between the initialization and post-steps.
![]() minor nit:
(if this was copied from another file, let me know which one and we'll fix that later). minor nit:
```suggestion
```
(if this was copied from another file, let me know which one and we'll fix that later).
![]() maybe
for a tiny bit more symmetry between the initialization and post-steps. maybe
```suggestion
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); i, p = i + 1, p + unsafe.Sizeof(C.git_message_trailer{}) {
```
for a tiny bit more symmetry between the initialization and post-steps.
|
|||||||
value string
|
Value string
|
||||||
![]() minor nit:
(if this was copied from another file, let me know which one and we'll fix that later). minor nit:
```suggestion
```
(if this was copied from another file, let me know which one and we'll fix that later).
![]() maybe
for a tiny bit more symmetry between the initialization and post-steps. maybe
```suggestion
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); i, p = i + 1, p + unsafe.Sizeof(C.git_message_trailer{}) {
```
for a tiny bit more symmetry between the initialization and post-steps.
![]() minor nit:
(if this was copied from another file, let me know which one and we'll fix that later). minor nit:
```suggestion
```
(if this was copied from another file, let me know which one and we'll fix that later).
![]() maybe
for a tiny bit more symmetry between the initialization and post-steps. maybe
```suggestion
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); i, p = i + 1, p + unsafe.Sizeof(C.git_message_trailer{}) {
```
for a tiny bit more symmetry between the initialization and post-steps.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MessageTrailers parses trailers out of a message, returning a slice of
|
// MessageTrailers parses trailers out of a message, returning a slice of
|
||||||
|
@ -37,7 +37,7 @@ func MessageTrailers(message string) ([]Trailer, error) {
|
||||||
![]() minor nit:
(if this was copied from another file, let me know which one and we'll fix that later). minor nit:
```suggestion
```
(if this was copied from another file, let me know which one and we'll fix that later).
![]() minor nit:
(if this was copied from another file, let me know which one and we'll fix that later). minor nit:
```suggestion
```
(if this was copied from another file, let me know which one and we'll fix that later).
![]() maybe
for a tiny bit more symmetry between the initialization and post-steps. maybe
```suggestion
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); i, p = i + 1, p + unsafe.Sizeof(C.git_message_trailer{}) {
```
for a tiny bit more symmetry between the initialization and post-steps.
![]() maybe
for a tiny bit more symmetry between the initialization and post-steps. maybe
```suggestion
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); i, p = i + 1, p + unsafe.Sizeof(C.git_message_trailer{}) {
```
for a tiny bit more symmetry between the initialization and post-steps.
|
|||||||
var trailer *C.git_message_trailer
|
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{}) {
|
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))
|
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)}
|
||||||
![]() minor nit:
(if this was copied from another file, let me know which one and we'll fix that later). minor nit:
```suggestion
```
(if this was copied from another file, let me know which one and we'll fix that later).
![]() maybe
for a tiny bit more symmetry between the initialization and post-steps. maybe
```suggestion
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); i, p = i + 1, p + unsafe.Sizeof(C.git_message_trailer{}) {
```
for a tiny bit more symmetry between the initialization and post-steps.
![]() minor nit:
(if this was copied from another file, let me know which one and we'll fix that later). minor nit:
```suggestion
```
(if this was copied from another file, let me know which one and we'll fix that later).
![]() maybe
for a tiny bit more symmetry between the initialization and post-steps. maybe
```suggestion
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); i, p = i + 1, p + unsafe.Sizeof(C.git_message_trailer{}) {
```
for a tiny bit more symmetry between the initialization and post-steps.
|
|||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
return trailers, nil
|
return trailers, nil
|
||||||
|
|
||||||
![]() minor nit:
(if this was copied from another file, let me know which one and we'll fix that later). minor nit:
```suggestion
```
(if this was copied from another file, let me know which one and we'll fix that later).
![]() minor nit:
(if this was copied from another file, let me know which one and we'll fix that later). minor nit:
```suggestion
```
(if this was copied from another file, let me know which one and we'll fix that later).
![]() maybe
for a tiny bit more symmetry between the initialization and post-steps. maybe
```suggestion
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); i, p = i + 1, p + unsafe.Sizeof(C.git_message_trailer{}) {
```
for a tiny bit more symmetry between the initialization and post-steps.
![]() maybe
for a tiny bit more symmetry between the initialization and post-steps. maybe
```suggestion
for i, p := 0, uintptr(unsafe.Pointer(trailersC.trailers)); i < int(trailersC.count); i, p = i + 1, p + unsafe.Sizeof(C.git_message_trailer{}) {
```
for a tiny bit more symmetry between the initialization and post-steps.
|
|
@ -19,14 +19,14 @@ func TestTrailers(t *testing.T) {
|
||||||
{
|
{
|
||||||
"commit with one trailer\n\nCo-authored-by: Alice <alice@example.com>\n",
|
"commit with one trailer\n\nCo-authored-by: Alice <alice@example.com>\n",
|
||||||
[]Trailer{
|
[]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",
|
"commit with two trailers\n\nCo-authored-by: Alice <alice@example.com>\nSigned-off-by: Bob <bob@example.com>\n",
|
||||||
[]Trailer{
|
[]Trailer{
|
||||||
Trailer{key: "Co-authored-by", value: "Alice <alice@example.com>"},
|
Trailer{Key: "Co-authored-by", Value: "Alice <alice@example.com>"},
|
||||||
Trailer{key: "Signed-off-by", value: "Bob <bob@example.com>"}},
|
Trailer{Key: "Signed-off-by", Value: "Bob <bob@example.com>"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
minor nit:
(if this was copied from another file, let me know which one and we'll fix that later).
minor nit:
(if this was copied from another file, let me know which one and we'll fix that later).
maybe
for a tiny bit more symmetry between the initialization and post-steps.
maybe
for a tiny bit more symmetry between the initialization and post-steps.