Skip to content

Commit

Permalink
Merge Curators and Docs maintainers.
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
  • Loading branch information
vdemeester committed Mar 18, 2016
1 parent 2342879 commit ad3231a
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions maintainercollector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func main() {
People: map[string]Person{},
}

// initialize Curators
projectMaintainers.Org["Curators"] = &Org{}
projectMaintainers.Org["Docs maintainers"] = &Org{}

// parse the MAINTAINERS file for each repo
for _, project := range projects {
maintainers, err := getMaintainers(project)
Expand All @@ -94,11 +98,11 @@ func main() {
projectMaintainers.Org[project] = p

if maintainers.Organization.DocsMaintainers != nil {
projectMaintainers.Org["Docs maintainers"] = maintainers.Organization.DocsMaintainers
projectMaintainers.Org["Docs maintainers"].People = append(projectMaintainers.Org["Docs maintainers"].People, maintainers.Organization.DocsMaintainers.People...)
}

if maintainers.Organization.Curators != nil {
projectMaintainers.Org["Curators"] = maintainers.Organization.Curators
projectMaintainers.Org["Curators"].People = append(projectMaintainers.Org["Curators"].People, maintainers.Organization.Curators.People...)
}

// iterate through the people and add them to compiled list
Expand All @@ -107,6 +111,9 @@ func main() {
}
}

projectMaintainers.Org["Curators"].People = removeDuplicates(projectMaintainers.Org["Curators"].People)
projectMaintainers.Org["Docs maintainers"].People = removeDuplicates(projectMaintainers.Org["Docs maintainers"].People)

// encode the result to a file
buf := new(bytes.Buffer)
t := toml.NewEncoder(buf)
Expand All @@ -126,6 +133,18 @@ func main() {
logrus.Infof("Successfully wrote new combined MAINTAINERS file.")
}

func removeDuplicates(slice []string) []string {
seens := map[string]bool{}
uniqs := []string{}
for _, element := range slice {
if _, seen := seens[element]; !seen {
uniqs = append(uniqs, element)
seens[element] = true
}
}
return uniqs
}

func getMaintainers(project string) (maintainers MaintainersDepreciated, err error) {
fileUrl := fmt.Sprintf("%s/%s/%s/master/MAINTAINERS", ghRawUri, org, project)
resp, err := http.Get(fileUrl)
Expand Down

0 comments on commit ad3231a

Please sign in to comment.