mirror of
https://github.com/bluekeyes/go-gitdiff
synced 2026-06-08 13:18:30 +00:00
Run 'go fix' to modernize code (#69)
This only updates to Go 1.21 baseline, which is what the module still specifies as the minimum version. I'll need to run this again when moving to Go 1.25 or 1.26 as minimum.
This commit is contained in:
@@ -186,9 +186,9 @@ func ParsePatchHeader(header string, options ...PatchHeaderOption) (*PatchHeader
|
||||
}
|
||||
|
||||
var firstLine, rest string
|
||||
if idx := strings.IndexByte(header, '\n'); idx >= 0 {
|
||||
firstLine = header[:idx]
|
||||
rest = header[idx+1:]
|
||||
if before, after, ok := strings.Cut(header, "\n"); ok {
|
||||
firstLine = before
|
||||
rest = after
|
||||
} else {
|
||||
firstLine = header
|
||||
rest = ""
|
||||
@@ -362,8 +362,8 @@ func parseHeaderMail(mailLine string, r io.Reader, opts patchHeaderOptions) (*Pa
|
||||
|
||||
h := &PatchHeader{}
|
||||
|
||||
if strings.HasPrefix(mailLine, mailHeaderPrefix) {
|
||||
mailLine = strings.TrimPrefix(mailLine, mailHeaderPrefix)
|
||||
if after, ok := strings.CutPrefix(mailLine, mailHeaderPrefix); ok {
|
||||
mailLine = after
|
||||
if i := strings.IndexByte(mailLine, ' '); i > 0 {
|
||||
h.SHA = mailLine[:i]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user