-
Notifications
You must be signed in to change notification settings - Fork 77
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
adding RN106 and RN107 #4643
adding RN106 and RN107 #4643
Conversation
Changelog(s) in markdown:
|
Changelog(s) in markdown:
|
def _check_file_status( | ||
self, | ||
file_path: str, | ||
remote: str, | ||
branch: str, | ||
feature_branch_or_hash: Optional[str] = None, | ||
) -> str: | ||
"""Get the git status of a given file path | ||
Args: | ||
file_path (str): the file path to check | ||
remote (str): the used git remote | ||
branch (str): the used git branch | ||
feature_branch_or_hash (str | None): compare against a specific branch or commit | ||
Returns: | ||
str: the git status of the file (M, A, R, D). | ||
""" | ||
current_branch_or_hash = self.get_current_git_branch_or_hash() | ||
if not feature_branch_or_hash: | ||
feature_branch_or_hash = self.get_current_git_branch_or_hash() | ||
|
||
if remote: | ||
diff_line = self.repo.git.diff( | ||
"--name-status", | ||
f"{remote}/{branch}...{current_branch_or_hash}", | ||
f"{remote}/{branch}...{feature_branch_or_hash}", | ||
"--", | ||
file_path, | ||
) | ||
|
||
# if remote does not exist we are checking against the commit sha1 | ||
else: | ||
diff_line = self.repo.git.diff( | ||
"--name-status", f"{branch}...{current_branch_or_hash}", "--", file_path | ||
"--name-status", f"{branch}...{feature_branch_or_hash}", "--", file_path |
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.
to be able to get related files' git statuses per specific commits (for our use-case: current branch / master), I allowed passing a specific commit
def get_pack_latest_rn_version(pack_path: str, git_sha: Optional[str] = None) -> str: | ||
""" | ||
Extract all the Release notes from the pack and return the highest version of release note in the Pack. | ||
|
||
Return: | ||
(str): The lastest version of RN. | ||
""" | ||
list_of_files = glob.glob(pack_path + "/ReleaseNotes/*") | ||
if git_sha: | ||
git_util = GitUtil.from_content_path() | ||
list_of_files = git_util.list_files_in_dir(f"{pack_path}/ReleaseNotes", git_sha) | ||
else: | ||
list_of_files = glob.glob(f"{pack_path}/ReleaseNotes/*") |
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.
this change makes the Pack's latest_rn_version field correct per commit
git_sha=self.git_sha, | ||
prev_ver=self.old_base_content_object.git_sha | ||
if self.old_base_content_object | ||
else None, |
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.
now we can compare these versions to get the actual git status. we should do it for other related files.
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.
Can you open a ticket for that?
TestSuite/pack.py
Outdated
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.
I had two different tests with a pack named ApiModule and the test failed on FileExistsError
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.
Amazing job!
Approved with minor comments.
git_util = GitUtil.from_content_path() | ||
current_git_sha = git_util.get_current_commit_hash() |
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.
Not sure I fully understand all the change here, but are we sure it won't affect the way we load changed files?
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.
- renaming
git_sha
arg toprev_ver
just to avoid confusion between prev and current versions - passed
current_git_sha
to the object'sgit_sha
. from what I saw, the git_sha attribute is used only in:
a) related_files.py (which is what I fixed)
b) integration and script parsers to get the code - if git_sha not passed, it uses the current working dir (equivalent to current git sha), so allegedly nothing was changed. - passed
prev_ver
to old object'sgit_sha
.
With 2+3, we can calculate the git_status of related files correctly for each object (see changes in related_files.py and git_utils.py)
Related Issues
fixes: https://jira-dc.paloaltonetworks.com/browse/CIAC-12004
Description
Test PR: demisto/content#37074
Changes:
Note that in case of RN106, RN107 won't be raised
new validate job:
https://gitlab.xdr.pan.local/xdr/cortex-content/content/-/jobs/10466680
old validate job: https://gitlab.xdr.pan.local/xdr/cortex-content/content/-/jobs/10429679
for some reason, old validate raised RN106 for SplunkPy (instead of RN107).