Beispiel #1
0
 def __init__(self, file_path, modified_files=None, pack_name=None, added_files=None, ignored_errors=None,
              print_as_warnings=False):
     super().__init__(ignored_errors=ignored_errors, print_as_warnings=print_as_warnings)
     self.file_path = file_path
     self.modified_files = modified_files
     self.added_files = added_files
     self.pack_name = pack_name
     self.release_notes_path = get_release_notes_file_path(self.file_path)
     self.latest_release_notes = get_latest_release_notes_text(self.release_notes_path)
Beispiel #2
0
    def get_release_notes(cls, file_path, data):  # pylint: disable=unused-argument
        """
        Return the release notes relevant to the added yml file.

        :param file_path: yml/json (or package yml)
        :param data: object data
        :return: raw release notes or None in case of an error.
        """
        release_note_path = get_release_notes_file_path(file_path)

        return get_latest_release_notes_text(release_note_path)
Beispiel #3
0
 def __init__(self, release_notes_file_path, modified_files=None, pack_name=None, added_files=None, ignored_errors=None,
              print_as_warnings=False, suppress_print=False, json_file_path=None):
     super().__init__(ignored_errors=ignored_errors, print_as_warnings=print_as_warnings,
                      suppress_print=suppress_print, json_file_path=json_file_path)
     self.release_notes_file_path = release_notes_file_path
     self.modified_files = modified_files
     self.added_files = added_files
     self.pack_name = pack_name
     self.release_notes_path = get_release_notes_file_path(self.release_notes_file_path)
     self.latest_release_notes = get_latest_release_notes_text(self.release_notes_path)
     self.file_types_that_should_not_appear_in_rn = {FileType.TEST_SCRIPT, FileType.TEST_PLAYBOOK, FileType.README,
                                                     FileType.RELEASE_NOTES, None}
Beispiel #4
0
 def __init__(self, release_notes_file_path, modified_files=None, pack_name=None, added_files=None,
              ignored_errors=None,
              print_as_warnings=False, suppress_print=False, json_file_path=None, specific_validations=None):
     super().__init__(ignored_errors=ignored_errors, print_as_warnings=print_as_warnings,
                      suppress_print=suppress_print, json_file_path=json_file_path,
                      specific_validations=specific_validations)
     self.release_notes_file_path = release_notes_file_path
     self.modified_files = modified_files
     self.added_files = added_files
     self.pack_name = pack_name
     self.pack_path = os.path.join(PACKS_DIR, self.pack_name)
     self.release_notes_path = get_release_notes_file_path(self.release_notes_file_path)
     self.latest_release_notes = get_latest_release_notes_text(self.release_notes_path)
Beispiel #5
0
 def create_markdown(self, release_notes_path: str, rn_string: str,
                     changed_files: dict):
     if os.path.exists(release_notes_path) and self.update_type is not None:
         print_warning(
             f"Release notes were found at {release_notes_path}. Skipping")
     elif self.update_type is None:
         current_rn = get_latest_release_notes_text(release_notes_path)
         updated_rn = self.update_existing_rn(current_rn, changed_files)
         with open(release_notes_path, 'w') as fp:
             fp.write(updated_rn)
     else:
         with open(release_notes_path, 'w') as fp:
             fp.write(rn_string)
Beispiel #6
0
def test_get_latest_release_notes_text_invalid():
    """
    Given
    - Invalid release notes

    When
    - Running validation on release notes.

    Then
    - Ensure None is returned
    """
    PATH_TO_HERE = f'{git_path()}/demisto_sdk/tests/test_files/'
    file_path = os.path.join(PATH_TO_HERE, 'empty-RN.md')
    assert get_latest_release_notes_text(file_path) is None
Beispiel #7
0
 def create_markdown(self, release_notes_path: str, rn_string: str, changed_files: dict,
                     docker_image_name: Optional[str]):
     if os.path.exists(release_notes_path) and self.update_type is not None:
         print_warning(f"Release notes were found at {release_notes_path}. Skipping")
     elif self.update_type is None and self.specific_version is None:
         current_rn = get_latest_release_notes_text(release_notes_path)
         updated_rn = self.update_existing_rn(current_rn, changed_files)
         updated_rn = self.rn_with_docker_image(updated_rn, docker_image_name)
         with open(release_notes_path, 'w') as fp:
             fp.write(updated_rn)
     else:
         self.existing_rn_changed = True
         updated_rn = self.rn_with_docker_image(rn_string, docker_image_name)
         with open(release_notes_path, 'w') as fp:
             fp.write(updated_rn)
Beispiel #8
0
    def is_there_release_notes(self):
        """Validate that the file has proper release notes when modified.
        This function updates the class attribute self._is_valid.

        Returns:
            (bool): is there release notes
        """
        if os.path.isfile(self.file_path):
            rn_path = get_release_notes_file_path(self.file_path)
            release_notes = get_latest_release_notes_text(rn_path)

            # check release_notes file exists and contain text
            if release_notes is None:
                self.is_valid = False
                print_error("Missing release notes for: {}".format(self.file_path))
                return False
        return True
Beispiel #9
0
    def create_markdown(self, release_notes_path: str, rn_string: str,
                        changed_files: dict):
        """ Creates the new markdown and writes it to the release notes file.

            :param
                release_notes_path: The release notes file path
                rn_string: The rn data (if exists)
                changed_files: The changed files details
                docker_image_name: The docker image name

        """
        if os.path.exists(release_notes_path) and self.update_type is not None:
            print_warning(
                f"Release notes were found at {release_notes_path}. Skipping")
        elif self.update_type is None and self.specific_version is None:
            current_rn = get_latest_release_notes_text(release_notes_path)
            updated_rn = self.update_existing_rn(current_rn, changed_files)
            with open(release_notes_path, 'w') as fp:
                fp.write(updated_rn)
        else:
            self.existing_rn_changed = True
            with open(release_notes_path, 'w') as fp:
                fp.write(rn_string)
 def __init__(self, file_path):
     self.file_path = file_path
     self.release_notes_path = get_release_notes_file_path(self.file_path)
     self.latest_release_notes = get_latest_release_notes_text(
         self.release_notes_path)
     self.master_diff = self.get_master_diff()