MCPcopy Index your code
hub / github.com/syncthing/syncthing / extractCopyrights

Function extractCopyrights

script/copyrights.go:431–456  ·  view source on GitHub ↗
(license string, notice CopyrightNotice)

Source from the content-addressed store, hash-verified

429}
430
431func extractCopyrights(license string, notice CopyrightNotice) []string {
432 lines := strings.Split(license, "\n")
433
434 re := regexp.MustCompile(`(?i)^\s*(copyright\s*(?:©|\(c\)|©|19|20).*)$`)
435
436 copyrights := []string{}
437
438 for _, line := range lines {
439 if matches := re.FindStringSubmatch(strings.TrimSpace(line)); len(matches) == 2 {
440 copyright := strings.TrimSpace(matches[1])
441 re := regexp.MustCompile(`(?i)all rights reserved`)
442 copyright = re.ReplaceAllString(copyright, "")
443 copyright = strings.ReplaceAll(copyright, "©", "©")
444 copyright = strings.ReplaceAll(copyright, "(C)", "©")
445 copyright = strings.ReplaceAll(copyright, "(c)", "©")
446 copyright = strings.Trim(copyright, "., ")
447 copyrights = append(copyrights, copyright)
448 }
449 }
450
451 if len(copyrights) > 0 {
452 return copyrights
453 }
454
455 return []string{}
456}
457
458func defaultCopyright(n CopyrightNotice) string {
459 year := time.Now().Format("2006")

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected