Skip to content
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

Add some debug messages to release make command and some refactor #10535

Merged
merged 2 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ...git import get_current_branch, git_commit
from ...release import get_agent_requirement_line, update_agent_requirements, update_version_module
from ...utils import complete_valid_checks, get_bump_function, get_valid_checks, get_version_string
from ..console import CONTEXT_SETTINGS, abort, echo_info, echo_success, echo_waiting, echo_warning
from ..console import CONTEXT_SETTINGS, abort, echo_debug, echo_info, echo_success, echo_waiting, echo_warning
from . import changelog
from .show import changes

Expand Down Expand Up @@ -118,6 +118,7 @@ def make(ctx, checks, version, initial_release, skip_sign, sign_only, exclude, a
abort(f'Current version is {cur_version}, cannot bump to {version}')
else:
cur_version, changelog_types = ctx.invoke(changes, check=check, dry_run=True)
echo_debug(f'Current version: {cur_version}. Changes: {changelog_types}')
if not changelog_types:
echo_warning(f'No changes for {check}, skipping...')
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
from ....github import get_changelog_types, get_pr, parse_pr_numbers
from ....release import get_release_tag_string
from ....utils import complete_valid_checks, get_valid_checks, get_version_string
from ...console import CONTEXT_SETTINGS, abort, echo_failure, echo_info, echo_success, echo_warning, validate_check_arg
from ...console import (
CONTEXT_SETTINGS,
abort,
echo_debug,
echo_failure,
echo_info,
echo_success,
echo_warning,
validate_check_arg,
)


@click.command(context_settings=CONTEXT_SETTINGS, short_help='Show all the pending PRs for a given check.')
Expand Down Expand Up @@ -49,37 +58,32 @@ def changes(ctx, check, tag_pattern, tag_prefix, dry_run, organization, since, e
if not dry_run:
echo_info(f'Found {len(pr_numbers)} PRs merged since tag: {target_tag}')

applicable_changelog_types = []
user_config = ctx.obj
if dry_run:
changelog_types = []

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
current_changelog_types = get_changelog_types(payload)
if not current_changelog_types:
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(current_changelog_types) > 1:
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 = current_changelog_types[0]
current_changelog_type = changelog_types[0]
if current_changelog_type != 'no-changelog':
changelog_types.append(current_changelog_type)

return cur_version, changelog_types
else:
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)

echo_debug(f'Found change {current_changelog_type}')
applicable_changelog_types.append(current_changelog_type)
else:
echo_debug(f'Found no-change change for PR {pr_num}, skipping')
hithwen marked this conversation as resolved.
Show resolved Hide resolved
else:
echo_success(payload.get('title'))
echo_info(f" * Url: {payload.get('html_url')}")

Expand All @@ -90,3 +94,5 @@ def changes(ctx, check, tag_pattern, tag_prefix, dry_run, organization, since, e
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