Repository navigation
- Auto-scan roles/*.json on startup and merge into built-in roles - #2891
Merged
Merged
Conversation
- Same title overrides built-in role; different title appends as new - roles/ directory is optional — no impact when absent Users can now add custom roles by simply dropping a .json file into the roles/ directory and restarting. No config changes needed.
Owner
|
thanks for the quick turnaround, this is exactly the right approach! Keeping roles.json untouched and scanning an optional roles/ directory makes it fully backward compatible: default installs are unaffected (the os.path.isdir guard skips when the dir is absent), and per-file load failures are caught so they can't break plugin init. Clean and minimal. Merging now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Users can now add custom roles by simply dropping a .json file
into the roles/ directory and restarting. No config changes needed.
What does this PR do?
Previously, adding a custom role required editing
roles.jsondirectly,which is bundled with the plugin and easily overwritten on updates.
This PR adds an optional
roles/directory: users can place individual.jsonrole files there, and they are auto-loaded and merged on startup.A role with the same
titleas a built-in one overrides it; otherwiseit is appended as a new role. No mapping files or config changes needed.
Changes
role.pyroles/directory scan in__init__and new_load_role_filemethodREADME.mdroles/directory usage_load_role_file(filepath).jsonrole file; iftitlematches an existing role, evict it from__init__(modified)roles.json, scanroles/for*.jsonfiles and merge them via_load_role_file. Clean up empty tags afterward.Type of change
Checklist