(ctx, check, tag_pattern, tag_prefix, dry_run, organization, since, exclude_branch)
return cur_version, applicable_changelog_types
Show all the pending PRs for a given check.
Show all the pending PRs for a given check.
Show all the pending PRs for a given check .
def changes(ctx, check, tag_pattern, tag_prefix, dry_run, organization, since, exclude_branch):
    """Show all the pending PRs for a given check."""
    if not dry_run and check and check not in get_valid_checks():
        abort(f'Check `{check}` is not an Agent-based Integration')

    # get the name of the current release tag
    cur_version = since or get_version_string(check, pattern=tag_pattern, tag_prefix=tag_prefix)
    if not cur_version:
        abort(
            'Failed to retrieve the latest version. Please ensure your project or check has a proper set of tags '
            'following SemVer and matches the provided tag_prefix and/or tag_pattern.'
        )
    target_tag = get_release_tag_string(check, cur_version)

    # get the diff from HEAD
    diff_lines = get_commits_since(check, target_tag, exclude_branch=exclude_branch)

    # for each PR get the title, we'll use it to populate the changelog
    pr_numbers = parse_pr_numbers(diff_lines)
    if not dry_run:
        echo_info(f'Found {len(pr_numbers)} PRs merged since tag: {target_tag}')

    applicable_changelog_types = []
    user_config = ctx.obj
    echo_debug(f'Evaluating PRs: {pr_numbers}')
    for pr_num in pr_numbers:
        try:
            payload = get_pr(pr_num, user_config, org=organization)
        except Exception as e:
            echo_failure(f'Unable to fetch info for PR #{pr_num}: {e}')
            continue
        changelog_types = get_changelog_types(payload)
        if dry_run:
            echo_debug('Running changes in dry run mode. Command will abort if there are invalid tags')
            if not changelog_types:
                echo_failure(f'No valid changelog labels found attached to PR #{pr_num}, please add one!')
                abort(f'No valid changelog labels found attached to PR #{pr_num}, please add one!')
            elif len(changelog_types) > 1:
                echo_failure(f'Multiple changelog labels found attached to PR #{pr_num}, please only use one!')
                abort(f'Multiple changelog labels found attached to PR #{pr_num}, please only use one!')

            current_changelog_type = changelog_types[0]
            if current_changelog_type != 'no-changelog':
                echo_debug(f'Found change {current_changelog_type}')
                applicable_changelog_types.append(current_changelog_type)
            else:
                echo_debug(f'Found no-changelog change for PR {pr_num}, skipping')
        else:
            echo_success(payload.get('title'))
            echo_info(f" * Url: {payload.get('html_url')}")

            echo_info(' * Changelog status: ', nl=False)
            if not changelog_types:
                echo_warning('WARNING! No changelog labels attached.\n')
            elif len(changelog_types) > 1:
                echo_warning(f"WARNING! Too many changelog labels attached: {', '.join(changelog_types)}\n")
            else:
                echo_success(f'{changelog_types[0]}\n')

    return cur_version, applicable_changelog_types
def changes ( ctx , check , tag_pattern , tag_prefix , dry_run , organization , since , exclude_branch ) : if not dry_run and check and check not in get_valid_checks ( ) : abort ( f'Check `{check}` is not an Agent-based Integration' ) # get the name of the current release tag cur_version = since or get_version_string ( check , pattern = tag_pattern , tag_prefix = tag_prefix ) if not cur_version : abort ( 'Failed to retrieve the latest version. Please ensure your project or check has a proper set of tags ' 'following SemVer and matches the provided tag_prefix and/or tag_pattern.' ) target_tag = get_release_tag_string ( check , cur_version ) # get the diff from HEAD diff_lines = get_commits_since ( check , target_tag , exclude_branch = exclude_branch ) # for each PR get the title, we'll use it to populate the changelog pr_numbers = parse_pr_numbers ( diff_lines ) if not dry_run : echo_info ( f'Found {len(pr_numbers)} PRs merged since tag: {target_tag}' ) applicable_changelog_types = [ ] user_config = ctx . obj echo_debug ( f'Evaluating PRs: {pr_numbers}' ) for pr_num in pr_numbers : try : payload = get_pr ( pr_num , user_config , org = organization ) except Exception as e : echo_failure ( f'Unable to fetch info for PR #{pr_num}: {e}' ) continue changelog_types = get_changelog_types ( payload ) if dry_run : echo_debug ( 'Running changes in dry run mode. Command will abort if there are invalid tags' ) if not changelog_types : echo_failure ( f'No valid changelog labels found attached to PR #{pr_num}, please add one!' ) abort ( f'No valid changelog labels found attached to PR #{pr_num}, please add one!' ) elif len ( changelog_types ) > 1 : echo_failure ( f'Multiple changelog labels found attached to PR #{pr_num}, please only use one!' ) abort ( f'Multiple changelog labels found attached to PR #{pr_num}, please only use one!' ) current_changelog_type = changelog_types [ 0 ] if current_changelog_type != 'no-changelog' : echo_debug ( f'Found change {current_changelog_type}' ) applicable_changelog_types . append ( current_changelog_type ) else : echo_debug ( f'Found no-changelog change for PR {pr_num}, skipping' ) else : echo_success ( payload . get ( 'title' ) ) echo_info ( f" * Url: {payload.get('html_url')}" ) echo_info ( ' * Changelog status: ' , nl = False ) if not changelog_types : echo_warning ( 'WARNING! No changelog labels attached.\n' ) elif len ( changelog_types ) > 1 : echo_warning ( f"WARNING! Too many changelog labels attached: {', '.join(changelog_types)}\n" ) else : echo_success ( f'{changelog_types[0]}\n' ) return cur_version , applicable_changelog_types