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

Make changes and changelog command work with other repos #5331

Merged
merged 6 commits into from
Dec 24, 2019
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
Prev Previous commit
Refactor
  • Loading branch information
nmuesch committed Dec 24, 2019
commit 07469ca70ba093faf023a7a0396e43a4cd2ce517
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# (C) Datadog, Inc. 2018
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import os
import sys

import click

from ...tooling.constants import INTEGRATION_REPOS, set_root

try:
from textwrap import indent as __indent_text
except ImportError:
Expand Down Expand Up @@ -62,3 +65,14 @@ def abort(text=None, code=1, out=False):
if text is not None:
click.secho(text, fg='red', bold=True, err=not out, color=DISPLAY_COLOR)
sys.exit(code)


def validate_check_arg(ctx, param, value):
# Treat '.' as a special value, meaning run the command against a repository, not an individual check
if value == '.':
if os.getcwd() in INTEGRATION_REPOS:
raise click.BadParameter('Needs to be the name of a real check or `.` for other repositories')
else:
set_root(os.getcwd())
return
return value
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from ...git import get_commits_since
from ...github import from_contributor, get_changelog_types, get_pr, parse_pr_numbers
from ...release import get_release_tag_string
from ...utils import get_valid_checks, get_version_string, validate_check_arg
from ..console import CONTEXT_SETTINGS, abort, echo_failure, echo_info
from ...utils import get_valid_checks, get_version_string
from ..console import CONTEXT_SETTINGS, abort, echo_failure, echo_info, validate_check_arg

ChangelogEntry = namedtuple('ChangelogEntry', 'number, title, url, author, author_url, from_contributor')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from ....git import get_commits_since
from ....github import get_changelog_types, get_pr, parse_pr_numbers
from ....release import get_release_tag_string
from ....utils import get_valid_checks, get_version_string, validate_check_arg
from ...console import CONTEXT_SETTINGS, abort, echo_failure, echo_info, echo_success, echo_warning
from ....utils import get_valid_checks, get_version_string
from ...console import CONTEXT_SETTINGS, abort, 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
CHANGELOG_TYPE_NONE = 'no-changelog'
INTEGRATION_REPOS = [
'integrations-core',
'integrations-internal',
'integrations-extras',
'integrations-internal',
]
VERSION_BUMP = OrderedDict(
[
Expand Down
2 changes: 1 addition & 1 deletion datadog_checks_dev/datadog_checks/dev/tooling/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import requests

from .constants import CHANGELOG_LABEL_PREFIX, get_root
from ..utils import basepath
from .constants import CHANGELOG_LABEL_PREFIX, get_root

API_URL = 'https://api.github.com'
PR_ENDPOINT = API_URL + '/repos/DataDog/{}/pulls/{}'
Expand Down
14 changes: 1 addition & 13 deletions datadog_checks_dev/datadog_checks/dev/tooling/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
from ast import literal_eval
from collections import OrderedDict

import click
import requests
import semver
from six import string_types

from ..utils import file_exists, read_file
from .constants import INTEGRATION_REPOS, NOT_CHECKS, VERSION_BUMP, get_root, set_root
from .constants import NOT_CHECKS, VERSION_BUMP, get_root
from .git import get_latest_tag

# match integration's version within the __about__.py module
Expand Down Expand Up @@ -205,14 +204,3 @@ def parse_version_parts(version):
if not isinstance(version, string_types):
return []
return [int(v) for v in version.split('.') if v.isdigit()]


def validate_check_arg(ctx, param, value):
# Treat '.' as a special value, meaning run the command against a repository, not an individual check
if value == '.':
if os.getcwd() in INTEGRATION_REPOS:
raise click.BadParameter('Needs to be the name of a real check or `.` for other repositories')
else:
set_root(os.getcwd())
return
return value