-
Notifications
You must be signed in to change notification settings - Fork 385
Add --category to marketplace package add/set #2626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,6 +151,12 @@ def _validate_subdir(subdir: str) -> None: | |
| raise MarketplaceYmlError(str(exc)) from exc | ||
|
|
||
|
|
||
| def _validate_category(category: str) -> None: | ||
| """Validate *category* is a non-empty string.""" | ||
| if not isinstance(category, str) or not category.strip(): | ||
| raise MarketplaceYmlError("'category' must be a non-empty string") | ||
|
|
||
|
|
||
| # ------------------------------------------------------------------- | ||
| # Public API | ||
| # ------------------------------------------------------------------- | ||
|
|
@@ -167,6 +173,7 @@ def add_plugin_entry( | |
| tag_pattern: str | None = None, | ||
| tags: list[str] | None = None, | ||
| include_prerelease: bool = False, | ||
| category: str | None = None, | ||
| ) -> str: | ||
| """Append a new entry to ``packages[]``. | ||
|
|
||
|
|
@@ -188,6 +195,9 @@ def add_plugin_entry( | |
| if subdir is not None: | ||
| _validate_subdir(subdir) | ||
|
|
||
| if category is not None: | ||
| _validate_category(category) | ||
|
|
||
| # Derive name from source repo if not provided. | ||
| if name is None: | ||
| name = _default_name_from_source(source) | ||
|
|
@@ -225,6 +235,8 @@ def add_plugin_entry( | |
| new_entry["include_prerelease"] = True | ||
| if tags is not None and len(tags) > 0: | ||
| new_entry["tags"] = tags | ||
| if category is not None: | ||
| new_entry["category"] = category | ||
|
Comment on lines
+239
to
+240
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 5b89a07: the stripped value is what gets stored, at both call sites. |
||
|
|
||
| packages.append(new_entry) | ||
|
|
||
|
|
@@ -267,11 +279,13 @@ def update_plugin_entry(yml_path: Path, name: str, **fields) -> None: | |
| del entry["version"] | ||
|
|
||
| # Simple scalar fields. | ||
| _SIMPLE_FIELDS = ("subdir", "tag_pattern") | ||
| _SIMPLE_FIELDS = ("subdir", "tag_pattern", "category") | ||
| for key in _SIMPLE_FIELDS: | ||
| if key in fields and fields[key] is not None: | ||
| if key == "subdir": | ||
| _validate_subdir(fields[key]) | ||
| elif key == "category": | ||
| _validate_category(fields[key]) | ||
| entry[key] = fields[key] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 5b89a07: the stripped value is what gets stored, at both call sites. |
||
|
|
||
| # Boolean field: include_prerelease. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5b89a07.
_validate_category()now returns the stripped value and both call sites store what it returns, so--category " Productivity "writesProductivity. Two regression tests cover the add and update paths.