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

Function main

script/copyrights.go:98–210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96var copyrightRe = regexp.MustCompile(`(?s)id="copyright-notices">(.+?)</ul>`)
97
98func 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

Callers

nothing calls this directly

Calls 10

readAllFunction · 0.85
getModulesFunction · 0.85
parseCopyrightNoticesFunction · 0.85
defaultCopyrightFunction · 0.85
parseGitHubURLFunction · 0.85
getLicenseTextFunction · 0.85
extractCopyrightsFunction · 0.85
writeFunction · 0.85
FatalMethod · 0.80
ContainsMethod · 0.80

Tested by

no test coverage detected