Commit 8399589
fix(ego-lint): avoid false FAIL when enum-id precedes schema-id in check-schema (#148)
## Problem
`check-schema.sh` extracts the schema ID using:
```bash
grep -oP 'id="[^"]*"' "$schema_file" | head -1 | sed 's/id="//;s/"//'
```
This grabs the **first** `id=` attribute in the file — which may belong
to a `<enum>` element that appears before the `<schema>` element.
**Reproduced on caffeine** (`caffeine@patapon.info`): the schema file
defines three `<enum id="...">` elements before `<schema
id="org.gnome.shell.extensions.caffeine">`. The old code extracted the
enum ID (`org.gnome.shell.extensions.caffeine.context-control`), causing
two false FAILs:
- `schema/id-matches` — ID didn't match `metadata.json settings-schema`
- `schema/filename-convention` — expected filename based on wrong ID
## Fix
Introduce `extract_schema_id()` helper that pre-filters to lines
matching `<schema\b` before extracting `id=`:
```bash
extract_schema_id() {
local file="$1"
grep -P '<schema\b' "$file" | grep -oP 'id="[^"]*"' | head -1 | sed 's/id="//;s/"//'
}
```
The old inline one-liner is replaced at all three call sites
(`schema/id-matches`, `schema/filename-convention`,
`schema/gnome-trademark`).
## Test
Before fix on caffeine:
```
FAIL|schema/id-matches|Schema ID 'org.gnome.shell.extensions.caffeine.context-control' does not match ...
FAIL|schema/filename-convention|Schema filename 'org.gnome.shell.extensions.caffeine.gschema.xml' MUST be '...'
```
After fix on caffeine:
```
PASS|schema/id-matches|Schema ID 'org.gnome.shell.extensions.caffeine' matches metadata.json settings-schema
PASS|schema/filename-convention|Schema filename matches ID: org.gnome.shell.extensions.caffeine.gschema.xml
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Solomon <sol@nanoclaw.dev>1 parent 2962779 commit 8399589
1 file changed
+14
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
11 | 21 | | |
12 | 22 | | |
13 | 23 | | |
| |||
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
56 | | - | |
57 | | - | |
| 66 | + | |
| 67 | + | |
58 | 68 | | |
59 | 69 | | |
60 | 70 | | |
| |||
65 | 75 | | |
66 | 76 | | |
67 | 77 | | |
68 | | - | |
| 78 | + | |
69 | 79 | | |
70 | 80 | | |
71 | 81 | | |
| |||
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
100 | | - | |
| 110 | + | |
101 | 111 | | |
102 | 112 | | |
103 | 113 | | |
| |||
0 commit comments