(h *gitdiff.PatchHeader, patchFile, message string)
| 436 | } |
| 437 | |
| 438 | func fillHeader(h *gitdiff.PatchHeader, patchFile, message string) *gitdiff.PatchHeader { |
| 439 | if h == nil { |
| 440 | h = &gitdiff.PatchHeader{} |
| 441 | } |
| 442 | |
| 443 | if message != "" { |
| 444 | h.Title, h.Body = splitMessage(message) |
| 445 | } |
| 446 | if h.Title == "" && h.Body == "" { |
| 447 | if patchFile == "-" { |
| 448 | h.Title = "Apply patch from stdin" |
| 449 | } else { |
| 450 | h.Title = fmt.Sprintf("Apply %s", patchFile) |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | if envAuthor := idFromEnv("AUTHOR"); envAuthor != nil { |
| 455 | h.Author = envAuthor |
| 456 | } |
| 457 | if envAuthorDate := dateFromEnv("AUHTOR"); !envAuthorDate.IsZero() { |
| 458 | h.AuthorDate = envAuthorDate |
| 459 | } |
| 460 | if envCommitter := idFromEnv("COMMITTER"); envCommitter != nil { |
| 461 | h.Committer = envCommitter |
| 462 | } |
| 463 | if envCommitterDate := dateFromEnv("COMMITTER"); !envCommitterDate.IsZero() { |
| 464 | h.CommitterDate = envCommitterDate |
| 465 | } |
| 466 | |
| 467 | return h |
| 468 | } |
| 469 | |
| 470 | func idFromEnv(idType string) *gitdiff.PatchIdentity { |
| 471 | name, hasName := os.LookupEnv(fmt.Sprintf("GIT_%s_NAME", idType)) |
no test coverage detected