()
| 96 | var copyrightRe = regexp.MustCompile(`(?s)id="copyright-notices">(.+?)</ul>`) |
| 97 | |
| 98 | func main() { |
| 99 | bs := readAll(htmlFile) |
| 100 | matches := copyrightRe.FindStringSubmatch(string(bs)) |
| 101 | |
| 102 | if len(matches) <= 1 { |
| 103 | log.Fatal("Cannot find id copyright-notices in ", htmlFile) |
| 104 | } |
| 105 | |
| 106 | modules := getModules() |
| 107 | |
| 108 | notices := parseCopyrightNotices(matches[1]) |
| 109 | old := len(notices) |
| 110 | |
| 111 | // match up modules to notices |
| 112 | matched := map[string]bool{} |
| 113 | removes := 0 |
| 114 | for i, notice := range notices { |
| 115 | if notice.Type == TypeJS { |
| 116 | continue |
| 117 | } |
| 118 | found := "" |
| 119 | for _, module := range modules { |
| 120 | if strings.Contains(module, notice.Name) { |
| 121 | found = module |
| 122 | |
| 123 | break |
| 124 | } |
| 125 | } |
| 126 | if found != "" { |
| 127 | matched[found] = true |
| 128 | notices[i].Module = found |
| 129 | |
| 130 | continue |
| 131 | } |
| 132 | removes++ |
| 133 | fmt.Printf("Removing: %-40s %-55s %s\n", notice.Name, notice.URL, notice.Copyright) |
| 134 | notices[i].Type = TypeToss |
| 135 | } |
| 136 | |
| 137 | // add new modules to notices |
| 138 | adds := 0 |
| 139 | for _, module := range modules { |
| 140 | _, ok := matched[module] |
| 141 | if ok { |
| 142 | continue |
| 143 | } |
| 144 | |
| 145 | adds++ |
| 146 | notice := CopyrightNotice{} |
| 147 | notice.Name = module |
| 148 | if strings.HasPrefix(notice.Name, "github.com/") { |
| 149 | notice.Name = strings.ReplaceAll(notice.Name, "github.com/", "") |
| 150 | } |
| 151 | notice.Type = TypeNew |
| 152 | |
| 153 | url, ok := urlMap[module] |
| 154 | if ok { |
| 155 | notice.URL = url |
nothing calls this directly
no test coverage detected