mirror of
https://github.com/arduino/library-registry.git
synced 2025-05-19 08:13:41 +03:00
Add duplicate name check to registry data file validator
The registry data file must be manually edited when a library name change request is received. Each library must have a unique name, so it's important to verify that no duplicates are introduced through these edits.
This commit is contained in:
parent
1b52ec4f6d
commit
0c2685dbee
@ -39,7 +39,16 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(rawRepos, filteredRepos) {
|
if !reflect.DeepEqual(rawRepos, filteredRepos) {
|
||||||
fmt.Fprintln(os.Stderr, "error: Registry data file contains duplicate entries")
|
fmt.Fprintln(os.Stderr, "error: Registry data file contains duplicate URLs")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nameMap := make(map[string]bool)
|
||||||
|
for _, entry := range rawRepos {
|
||||||
|
if _, found := nameMap[entry.LibraryName]; found {
|
||||||
|
fmt.Fprintf(os.Stderr, "error: Registry data file contains duplicates of name %s\n", entry.LibraryName)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
nameMap[entry.LibraryName] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ test_data_path = pathlib.Path(__file__).resolve().parent.joinpath("testdata")
|
|||||||
("invalid-data-format.txt", False),
|
("invalid-data-format.txt", False),
|
||||||
("invalid-url-format.txt", False),
|
("invalid-url-format.txt", False),
|
||||||
("duplicate-url.txt", False),
|
("duplicate-url.txt", False),
|
||||||
|
("duplicate-name.txt", False),
|
||||||
("valid.txt", True),
|
("valid.txt", True),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
4
.github/workflows/assets/validate-registry/tests/testdata/duplicate-name.txt
vendored
Normal file
4
.github/workflows/assets/validate-registry/tests/testdata/duplicate-name.txt
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
https://github.com/arduino-libraries/Scheduler.git|Arduino|Scheduler
|
||||||
|
https://github.com/arduino-libraries/SD.git|Partner|SD
|
||||||
|
https://github.com/arduino-libraries/Servo.git|Recommended|Servo
|
||||||
|
https://github.com/arduino-libraries/Foo.git|Contributed|SD
|
Loading…
x
Reference in New Issue
Block a user