@@ -14,6 +14,7 @@ import (
1414
1515 "coder.com/coder-registry/cmd/github"
1616 "github.com/go-git/go-git/v5"
17+ "github.com/go-git/go-git/v5/plumbing"
1718 "github.com/joho/godotenv"
1819)
1920
@@ -66,7 +67,10 @@ func main() {
6667 // Start main validation
6768 log .Println ("Starting README validation" )
6869
69- // Validate file structure of main README directory
70+ // Validate file structure of main README directory. Have to do this
71+ // synchronously and before everything else, or else there's no way to for
72+ // the other main validation functions can't make any safe assumptions
73+ // about where they should look in the repo
7074 log .Println ("Validating directory structure of the README directory" )
7175 err = validateRepoStructure ()
7276 if err != nil {
@@ -76,18 +80,22 @@ func main() {
7680 // Set up concurrency for validating each category of README file
7781 var readmeValidationErrors []error
7882 errChan := make (chan error , 1 )
83+ doneChan := make (chan struct {})
7984 wg := sync.WaitGroup {}
8085 go func () {
8186 for err := range errChan {
8287 readmeValidationErrors = append (readmeValidationErrors , err )
8388 }
89+ close (doneChan )
8490 }()
8591
8692 // Validate contributor README files
8793 wg .Add (1 )
8894 go func () {
8995 defer wg .Done ()
90- validateAllContributors (errChan )
96+ if err := validateAllContributors (); err != nil {
97+ errChan <- fmt .Errorf ("contributor validation: %v" , err )
98+ }
9199 }()
92100
93101 // Validate modules
@@ -117,7 +125,11 @@ func main() {
117125 return
118126 }
119127 activeBranchName := head .Name ().Short ()
120- fmt .Println ("-----" , activeBranchName )
128+ _ , err = repo .Reference (plumbing .ReferenceName (activeBranchName ), true )
129+ if err != nil {
130+ errChan <- err
131+ return
132+ }
121133 }()
122134
123135 // Validate templates
@@ -126,9 +138,10 @@ func main() {
126138 defer wg .Done ()
127139 }()
128140
129- // Clean up and log errors
141+ // Clean up and then log errors
130142 wg .Wait ()
131143 close (errChan )
144+ <- doneChan
132145 for _ , err := range readmeValidationErrors {
133146 log .Println (err )
134147 }
0 commit comments