MCPcopy
hub / github.com/syncthing/syncthing / main

Function main

script/authors.go:65–119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63}
64
65func main() {
66 // Read authors from the AUTHORS file
67 authorSet := getAuthors()
68
69 // Grab the set of all known authors based on the git log, and add any
70 // missing ones to the authors list.
71 addAuthors(authorSet)
72
73 authors := authorSet.filteredAuthors()
74
75 // Write authors to the about dialog
76
77 slices.SortFunc(authors, func(a, b author) int {
78 return cmp.Or(
79 -cmp.Compare(a.log10commits, b.log10commits),
80 cmp.Compare(strings.ToLower(a.name), strings.ToLower(b.name)))
81 })
82
83 var lines []string
84 for _, author := range authors {
85 lines = append(lines, author.name)
86 }
87 replacement := strings.Join(lines, ", ")
88
89 authorsRe := regexp.MustCompile(`(?s)id="contributor-list">.*?</div>`)
90 bs, err := os.ReadFile(htmlFile)
91 if err != nil {
92 log.Fatal(err)
93 }
94 bs = authorsRe.ReplaceAll(bs, []byte("id=\"contributor-list\">\n"+replacement+"\n </div>"))
95
96 if err := os.WriteFile(htmlFile, bs, 0o644); err != nil {
97 log.Fatal(err)
98 }
99
100 // Write AUTHORS file
101
102 out, err := os.Create("AUTHORS")
103 if err != nil {
104 log.Fatal(err)
105 }
106
107 fmt.Fprintf(out, "%s\n", authorsHeader)
108 for _, author := range authors {
109 fmt.Fprintf(out, "%s", author.name)
110 if author.nickname != "" {
111 fmt.Fprintf(out, " (%s)", author.nickname)
112 }
113 for _, email := range author.emails {
114 fmt.Fprintf(out, " <%s>", email)
115 }
116 fmt.Fprint(out, "\n")
117 }
118 out.Close()
119}
120
121func getAuthors() *authorSet {
122 bs, err := os.ReadFile("AUTHORS")

Callers

nothing calls this directly

Calls 7

getAuthorsFunction · 0.85
addAuthorsFunction · 0.85
filteredAuthorsMethod · 0.80
FatalMethod · 0.80
CreateMethod · 0.65
CloseMethod · 0.65
CompareMethod · 0.45

Tested by

no test coverage detected