Skip to content
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

CIAC-8160: generate pack readme in marketplace contributions #4684

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changelog/4684.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Added the option to add content to the pack README of a new pack that was contributed through XSOAR UI.
type: feature
pr_number: 4684
7 changes: 7 additions & 0 deletions demisto_sdk/commands/init/contribution_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def __init__(
detected_content_items: list = [],
base_dir: Optional[str] = None,
working_dir_path: str = "",
pack_readme: str = "",
):
"""Initializes a ContributionConverter instance

Expand All @@ -154,8 +155,10 @@ def __init__(
base_dir (Union[str], optional): Used to explicitly pass the path to the top-level directory of the
local content repo. If no value is passed, the `CONTENT_PATH` variable is used to determine
the path. Defaults to None.
pack_readme (str): The content of the new pack readme, if create_new == True.

"""
self.pack_readme = pack_readme
self.configuration = Configuration()
self.contribution = contribution
self.description = description
Expand Down Expand Up @@ -745,6 +748,10 @@ def create_pack_base_files(self):
"""
logger.info("Creating pack base files")
Path(self.working_dir_path, PACKS_README_FILE_NAME).touch()
if self.pack_readme:
Path(self.working_dir_path, PACKS_README_FILE_NAME).write_text(
self.pack_readme
)

Path(self.working_dir_path, ".secrets-ignore").touch()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1502,13 +1502,18 @@ def test_process_new_pack(
create_new=True,
working_dir_path=str(contribution_temp_dir),
base_dir=git_repo.path,
pack_readme=readme,
)

# Convert the contribution to a pack
contrib_converter.convert_contribution_to_pack()

# Check new Pack README exists
assert Path(contrib_converter.working_dir_path, PACKS_README_FILE_NAME).exists()
content_pack_readme = Path(
contrib_converter.working_dir_path, PACKS_README_FILE_NAME
).read_text()
assert content_pack_readme == readme

# Check new Integration README exists
assert Path(contrib_converter.readme_files[0]).exists()
Expand Down