Commit f2371529a6
Unsigned
Layout: unified · split
.github/CONTRIBUTING.md +1 −1
| @@ -285,8 +285,8 @@ Below is the full list of checks - it's basically the same as what is listed in | ||
| 285 | 285 | - **Validating Addition** |
| 286 | 286 | - 🔴 **Schema valid** - YAML must pass schema validation |
| 287 | 287 | - 🔴 **Required fields** - Must include `name`, `description`, `url`, `icon` |
| 288 | - 🔴 **No mass changes** - Must not remove more than 5, or modify more than 10, existing listings | |
| 289 | 288 | - 🟡 **Single entry** - Only one service addition per PR |
| 289 | - 🟡 **No mass changes** - Should not remove more than 5, or modify more than 10, existing listings | |
| 290 | 290 | - 🟡 **Position** - New entries must go at the end of their section |
| 291 | 291 | - 🟡 **Open source** - Non-open-source submissions need justification |
| 292 | 292 | - 🟡 **Duplicate name** - Service name must not already exist |
lib/checks/check-additions.py +8 −7
| @@ -174,9 +174,10 @@ def check_single_entry(diff): | ||
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | def check_mass_changes(diff): |
| 177 | """Return a finding if the diff removes or modifies too many existing services.""" | |
| 177 | """Return a finding if the diff removes or modifies too many existing services, excluding moves.""" | |
| 178 | 178 | services = diff.get("services", {}) |
| 179 | removed = len(services.get("removed", [])) | |
| 179 | added_names = {s.get("service") for s in services.get("added", [])} | |
| 180 | removed = sum(1 for s in services.get("removed", []) if s.get("service") not in added_names) | |
| 180 | 181 | modified = len(services.get("modified", [])) |
| 181 | 182 | if removed > MAX_REMOVED_LISTINGS or modified > MAX_MODIFIED_LISTINGS: |
| 182 | 183 | return MASS_CHANGE_MSG.format(removed=removed, modified=modified) |
| @@ -187,7 +188,7 @@ def _added_keys(diff): | ||
| 187 | 188 | """Build a set of (category, section, lowercase_name) for added services.""" |
| 188 | 189 | keys = set() |
| 189 | 190 | for svc in diff.get("services", {}).get("added", []): |
| 190 | name = svc.get("fields", {}).get("name", "").lower().strip() | |
| 191 | name = (svc.get("fields", {}).get("name") or "").lower().strip() | |
| 191 | 192 | keys.add((svc.get("category", ""), svc.get("section", ""), name)) |
| 192 | 193 | return keys |
| 193 | 194 | |
| @@ -203,7 +204,7 @@ def build_name_index(head, diff): | ||
| 203 | 204 | for sec in cat.get("sections", []): |
| 204 | 205 | sn = sec.get("name", "") |
| 205 | 206 | for svc in sec.get("services", []): |
| 206 | name = svc.get("name", "").lower().strip() | |
| 207 | name = (svc.get("name") or "").lower().strip() | |
| 207 | 208 | if name and (cn, sn, name) not in exclude: |
| 208 | 209 | index[name] = f"{cn} > {sn}" |
| 209 | 210 | return index |
| @@ -220,7 +221,7 @@ def build_url_index(head, diff): | ||
| 220 | 221 | for sec in cat.get("sections", []): |
| 221 | 222 | sn = sec.get("name", "") |
| 222 | 223 | for svc in sec.get("services", []): |
| 223 | name = svc.get("name", "").lower().strip() | |
| 224 | name = (svc.get("name") or "").lower().strip() | |
| 224 | 225 | if (cn, sn, name) in exclude: |
| 225 | 226 | continue |
| 226 | 227 | url = svc.get("url", "") |
| @@ -232,7 +233,7 @@ def build_url_index(head, diff): | ||
| 232 | 233 | def check_duplicate_name(diff, name_index): |
| 233 | 234 | """Return a finding if an added service name already exists in the YAML.""" |
| 234 | 235 | for svc in diff.get("services", {}).get("added", []): |
| 235 | name = svc.get("fields", {}).get("name", "").lower().strip() | |
| 236 | name = (svc.get("fields", {}).get("name") or "").lower().strip() | |
| 236 | 237 | if name and name in name_index: |
| 237 | 238 | return DUPLICATE_NAME_MSG.format( |
| 238 | 239 | name=svc["fields"]["name"], location=name_index[name], |
| @@ -315,7 +316,7 @@ def main(): | ||
| 315 | 316 | |
| 316 | 317 | checks = [ |
| 317 | 318 | ("single-entry", check_single_entry(diff), False), |
| 318 | ("mass-changes", check_mass_changes(diff), True), | |
| 319 | ("mass-changes", check_mass_changes(diff), False), | |
| 319 | 320 | ("required-fields", check_required_fields(diff, head), True), |
| 320 | 321 | ("position", check_position(diff, head), False), |
| 321 | 322 | ("open-source", check_open_source(diff), False), |