refactor: start making main() leaner
This commit is contained in:
parent
19226af067
commit
f23bbca2e7
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -371,3 +372,25 @@ func validateContributorRelativeUrls(contributors map[string]contributorProfile)
|
|||||||
errors: problems,
|
errors: problems,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func validateAllContributors(errChan chan<- error) {
|
||||||
|
allReadmeFiles, err := aggregateContributorReadmeFiles()
|
||||||
|
if err != nil {
|
||||||
|
errChan <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Printf("Processing %d README files\n", len(allReadmeFiles))
|
||||||
|
contributors, err := parseContributorFiles(allReadmeFiles)
|
||||||
|
log.Printf("Processed %d README files as valid contributor profiles", len(contributors))
|
||||||
|
if err != nil {
|
||||||
|
errChan <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = validateContributorRelativeUrls(contributors)
|
||||||
|
if err != nil {
|
||||||
|
errChan <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Println("All relative URLs for READMEs are valid")
|
||||||
|
log.Printf("Processed all READMEs in the %q directory\n", rootRegistryPath)
|
||||||
|
}
|
||||||
|
|||||||
@ -87,26 +87,7 @@ func main() {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
validateAllContributors(errChan)
|
||||||
allReadmeFiles, err := aggregateContributorReadmeFiles()
|
|
||||||
if err != nil {
|
|
||||||
errChan <- err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Printf("Processing %d README files\n", len(allReadmeFiles))
|
|
||||||
contributors, err := parseContributorFiles(allReadmeFiles)
|
|
||||||
log.Printf("Processed %d README files as valid contributor profiles", len(contributors))
|
|
||||||
if err != nil {
|
|
||||||
errChan <- err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = validateContributorRelativeUrls(contributors)
|
|
||||||
if err != nil {
|
|
||||||
errChan <- err
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Println("All relative URLs for READMEs are valid")
|
|
||||||
log.Printf("Processed all READMEs in the %q directory\n", rootRegistryPath)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Validate modules
|
// Validate modules
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user