MCPcopy Create free account
hub / github.com/bluekeyes/patch2pr / fillHeader

Function fillHeader

cmd/patch2pr/main.go:438–468  ·  view source on GitHub ↗
(h *gitdiff.PatchHeader, patchFile, message string)

Source from the content-addressed store, hash-verified

436}
437
438func 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
470func idFromEnv(idType string) *gitdiff.PatchIdentity {
471 name, hasName := os.LookupEnv(fmt.Sprintf("GIT_%s_NAME", idType))

Callers 1

executeFunction · 0.85

Calls 3

splitMessageFunction · 0.85
idFromEnvFunction · 0.85
dateFromEnvFunction · 0.85

Tested by

no test coverage detected