Skip to content

Commit

Permalink
Merge 5fd7b10 into 4e131a3
Browse files Browse the repository at this point in the history
  • Loading branch information
DinaMeylakh committed Jun 6, 2024
2 parents 4e131a3 + 5fd7b10 commit 990f7ed
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .changelog/4328.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Fixed an issue in the `download` command where downloading with force and run-format flags did not merge YML fields.
type: fix
pr_number: 4328
3 changes: 2 additions & 1 deletion demisto_sdk/commands/download/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ def write_files_into_output_path(
except Exception as e:
failed_downloads_count += 1
logger.error(
f"Failed to download content item '{content_item_name}': {e}"
f"Failed to download content item '{content_item_name}': {str(e)}"
)
logger.debug(traceback.format_exc())
continue
Expand All @@ -1377,6 +1377,7 @@ def write_files_into_output_path(
input=str(downloaded_file),
no_validate=False,
assume_answer=False,
clear_cache=True,
)

summary_log = ""
Expand Down
33 changes: 33 additions & 0 deletions demisto_sdk/commands/download/tests/downloader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,39 @@ def test_download_and_extract_existing_file(self, tmp_path):
code_data = code_file.read()
assert "# TEST" in code_data

def test_download_and_format_existing_file(self, tmp_path):
"""
Given: A remote Script with differernt comment.
When: Downloading with force=True and run_format=True.
Then: Assert the file is merged and the remote comment is formatted is in the new file.
"""
env = Environment(tmp_path)
downloader = Downloader(force=True, run_format=True)
script_file_name = env.SCRIPT_CUSTOM_CONTENT_OBJECT["file_name"]
script_file_path = env.SCRIPT_INSTANCE_PATH / "TestScript.yml"

script_data = get_file_details(
file_content=env.SCRIPT_CUSTOM_CONTENT_OBJECT["file"].getvalue(),
full_file_path=str(env.CUSTOM_CONTENT_SCRIPT_PATH),
)

# The downloaded yml contains some other comment now.
script_data["comment"] = "some other comment"

env.SCRIPT_CUSTOM_CONTENT_OBJECT["data"] = script_data

assert downloader.write_files_into_output_path(
downloaded_content_objects={
script_file_name: env.SCRIPT_CUSTOM_CONTENT_OBJECT
},
existing_pack_structure=env.PACK_CONTENT,
output_path=env.PACK_INSTANCE_PATH,
)
assert script_file_path.is_file()
data = get_yaml(script_file_path)
# Make sure the new comment is formatted and a '.' was added.
assert data["comment"] == "some other comment."

def test_download_existing_no_force_skip(self, tmp_path):
"""
Given: A Downloader object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pswd: ""
runas: DBotWeakRole
runonce: false
script: ''
fromversion: TEST
toversion: TEST
fromversion: 1.0.0
toversion: 1.0.0
alt_dockerimages: TEST
scripttarget: 0
subtype: python3
Expand Down
1 change: 1 addition & 0 deletions demisto_sdk/commands/format/format_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def format_manager(
deprecate=deprecate,
add_tests=add_tests,
graph=graph,
clear_cache=clear_cache,
)
if err_res:
log_list.extend([(err_res, "red")])
Expand Down
6 changes: 5 additions & 1 deletion demisto_sdk/commands/validate/old_validate_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,11 @@ def run_validations_on_file(
if (
file_type in self.skipped_file_types
or self.is_skipped_file(file_path)
or (self.git_util and self.git_util._is_file_git_ignored(file_path))
or (
self.use_git
and self.git_util
and self.git_util._is_file_git_ignored(file_path)
)
or detect_file_level(file_path)
in (PathLevel.PACKAGE, PathLevel.CONTENT_ENTITY_DIR)
):
Expand Down

0 comments on commit 990f7ed

Please sign in to comment.