@@ -85,17 +85,26 @@ for repo in "${repos[@]}"; do
8585
8686 # TODO also check for required keys and/or types?
8787 # the canonicalMetadataFile doesn't have too many categories since it is the source of categories
88- # all other metadata.json files must not be more than maxCategories
88+ # all other metadata.json files must not be more than maxCategories or have categories that aren't in the canonical set
8989 if [ " $repoFile " != " $canonicalMetadataFile " ]; then
90- if tooManyCategories=" $( jq --raw-output '
90+ export repoFile
91+ if errorText=" $( jq -r --slurpfile canonical " $canonicalMetadataFile " '
9192 .hub.categories
92- | length
93- | if . > (env.maxCategories | tonumber) then
94- .
95- else empty end
93+ | (
94+ length
95+ | if . > (env.maxCategories | tonumber) then
96+ "error: \(env.repoFile): too many categories: \(.) (max \(env.maxCategories))"
97+ else empty end
98+ ),
99+ (
100+ . - $canonical[0].hub.categories
101+ | if length > 0 then
102+ "error: \(env.repoFile): unknown categories \(.)"
103+ else empty end
104+ )
96105 ' " $repoFile " ) " ; then
97- if [ -n " $tooManyCategories " ]; then
98- echo >&2 " error: $repoFile : too many categories: $tooManyCategories (max $maxCategories ) "
106+ if [ -n " $errorText " ]; then
107+ echo >&2 " $errorText "
99108 (( failures++ )) || :
100109 fi
101110 else
@@ -104,20 +113,6 @@ for repo in "${repos[@]}"; do
104113 continue
105114 fi
106115 fi
107-
108- # check for categories that aren't in the canonical set
109- if extraCategories=" $( jq -c --slurpfile canonical " $canonicalMetadataFile " '
110- .hub.categories - $canonical[0].hub.categories
111- ' " $repoFile " ) " ; then
112- if [ " $extraCategories " != ' []' ]; then
113- echo >&2 " error: $repoFile : unkown categories: $extraCategories "
114- (( failures++ )) || :
115- fi
116- else
117- echo >&2 " error parsing '$repoFile '; invalid JSON?"
118- (( failures++ )) || :
119- continue
120- fi
121116done
122117
123118exit " $failures "
0 commit comments