()
| 63 | } |
| 64 | |
| 65 | func 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 | |
| 121 | func getAuthors() *authorSet { |
| 122 | bs, err := os.ReadFile("AUTHORS") |
nothing calls this directly
no test coverage detected