Add support for parsing git trailers #614

Merged
lollipopman merged 5 commits from trailers into master 2020-06-02 12:30:42 -05:00
2 changed files with 6 additions and 6 deletions
Showing only changes of commit ca080d554e - Show all commits

View File

@ -11,8 +11,8 @@ import (
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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.
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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.
// Trailer represents a single git message trailer.
type Trailer struct {
key string
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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.
Key string
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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
@ -37,7 +37,7 @@ func MessageTrailers(message string) ([]Trailer, error) {
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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.
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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
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)}
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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.
trailers[i] = Trailer{Key: C.GoString(trailer.key), Value: C.GoString(trailer.value)}
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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++
}
return trailers, nil

lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:39:38 -05:00 (Migrated from github.com)
Review

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).
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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.
lhchavez commented 2020-06-01 20:45:12 -05:00 (Migrated from github.com)
Review

maybe

	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 ```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.

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 {