コード例 #1
0
def create_release_notes(
    from_component: gci.componentmodel.Component,
    from_github_cfg,
    from_repo_owner: str,
    from_repo_name: str,
    to_version: str,
):
    from_version = from_component.version
    try:
        with tempfile.TemporaryDirectory() as temp_dir:
            gitutil.GitHelper.clone_into(
                target_directory=temp_dir,
                github_cfg=from_github_cfg,
                github_repo_path=f'{from_repo_owner}/{from_repo_name}')
            commit_range = '{from_version}..{to_version}'.format(
                from_version=from_version,
                to_version=to_version,
            )
            release_notes = ReleaseNotes(
                component=from_component,
                repo_dir=temp_dir,
            )
            release_notes.create(
                start_ref=None,  # the repo's default branch
                commit_range=commit_range)
            release_note_blocks = release_notes.release_note_blocks()
            if release_note_blocks:
                return f'**Release Notes**:\n{release_note_blocks}'
    except:
        logger.warning(
            'an error occurred during release notes processing (ignoring)')
        import traceback
        logger.warning(traceback.format_exc())
コード例 #2
0
    def test_multiple_release_note_objs_to_block_str(self):
        hostname = 'github.com'
        org_name = 's'
        repo_name = 'repo'

        rls_note_objs = [
            release_note_block_with_defaults(),
            release_note_block_with_defaults(
                reference_type=REF_TYPE_COMMIT,
                reference_id='commit-id',
                text='another one',
                source_component_hostname=hostname,
                source_component_org_name=org_name,
                source_component_repo_name=repo_name,
            ),
        ]
        exp_release_note_block = \
        '``` improvement user github.com/madeup/current-repo #42 @foo\n'\
        'default release note text'\
        '\n```'\
        '\n'\
        '\n'\
        f'``` improvement user {hostname}/{org_name}/{repo_name} $commit-id @foo\n'\
        'another one'\
        '\n```'
        release_notes = ReleaseNotes(
            component=CURRENT_COMPONENT,
            repo_dir='',
        )
        release_notes.release_note_objs = rls_note_objs
        self.assertEqual(
            exp_release_note_block,
            release_notes.release_note_blocks(),
        )
コード例 #3
0
    def test_no_release_note_obj_to_block_str(self):
        rls_note_objs = []
        exp_release_note_block = ''
        empty_notes = ReleaseNotes(CURRENT_COMPONENT, '')
        empty_notes.release_note_objs = rls_note_objs
        self.assertEqual(
            exp_release_note_block,
            empty_notes.release_note_blocks(),
        )

        empty_notes.release_note_objs = None
        exp_release_note_block = ''
        self.assertEqual(
            exp_release_note_block,
            empty_notes.release_note_blocks(),
        )
コード例 #4
0
    def test_single_release_note_obj_to_block_str(self):
        rls_note_objs = [release_note_block_with_defaults()]
        exp_release_note_block = \
        '``` improvement user github.com/madeup/current-repo #42 @foo\n'\
        'default release note text'\
        '\n```'
        release_notes = ReleaseNotes(
            component=CURRENT_COMPONENT,
            repo_dir='',
        )
        release_notes.release_note_objs = rls_note_objs

        self.assertEqual(exp_release_note_block,
                         release_notes.release_note_blocks())