# Path: releasetool/commands/tag/nodejs.py
# def _get_latest_release_notes(ctx: TagContext, changelog: str):
#     # the 'v' prefix is not used in the conventional-changelog templates
#     # used in automated CHANGELOG generation:
#     version = re.sub(r"^v", "", ctx.release_version)
#     match = re.search(
#         rf"## v?\[?{version}[^\n]*\n(?P<notes>.+?)(\n##\s|\n### \[?[0-9]+\.|\Z)",
#         changelog,
#         re.DOTALL | re.MULTILINE,
#     )
#     if match is not None:
#         ctx.release_notes = match.group("notes").strip()
#     else:
#         ctx.release_notes = ""
# 
# def kokoro_job_name(upstream_repo: str, package_name: str) -> Union[str, None]:
#     """Return the Kokoro job name.
# 
#     Args:
#         upstream_repo (str): The GitHub repo in the form of `<owner>/<repo>`
#         package_name (str): The name of package to release
# 
#     Returns:
#         The name of the Kokoro job to trigger or None if there is no job to trigger
#     """
#     return f"cloud-devrel/client-libraries/nodejs/release/{upstream_repo}/publish"
# 
# def package_name(pull: dict) -> Union[str, None]:
#     return None
# 
# Path: releasetool/commands/common.py
# class TagContext(GitHubContext):
#     release_pr: Optional[dict] = None
#     release_tag: Optional[str] = None
#     release_version: Optional[str] = None
#     github_release: Optional[dict] = None
#     kokoro_job_name: Optional[str] = None
#     fusion_url: Optional[str] = None
#     token: Optional[str] = None


from releasetool.commands.tag.nodejs import (
    _get_latest_release_notes,
    kokoro_job_name,
    package_name,
)
from releasetool.commands.common import TagContext
* adds a fancy new feature ([c46bfa3](https://www.github.com/bcoe/examples-conventional-commits/commit/c46bfa3))


### BREAKING CHANGES

* this fancy new feature breaks things
* disclaimer breaks everything"""
    ctx = TagContext(release_version="v2.0.0")
    _get_latest_release_notes(ctx, fixture_new_style_changelog)
    assert ctx.release_notes == expected


def test_extracts_appropriate_release_notes_when_prior_release_is_patch():
    """
    see: https://github.com/googleapis/release-please/issues/140
    """
    ctx = TagContext(release_version="v5.0.0")
    _get_latest_release_notes(ctx, fixture_new_style_patch)
    expected = """### ⚠ BREAKING CHANGES

* temp directory now defaults to setting for report directory

### Features

* default temp directory to report directory ([#102](https://www.github.com/bcoe/c8/issues/102)) ([8602f4a](https://www.github.com/bcoe/c8/commit/8602f4a))
* load .nycrc/.nycrc.json to simplify migration ([#100](https://www.github.com/bcoe/c8/issues/100)) ([bd7484f](https://www.github.com/bcoe/c8/commit/bd7484f))"""
    assert ctx.release_notes == expected


def test_kokoro_job_name():

# Path: releasetool/commands/tag/nodejs.py
# def _get_latest_release_notes(ctx: TagContext, changelog: str):
#     # the 'v' prefix is not used in the conventional-changelog templates
#     # used in automated CHANGELOG generation:
#     version = re.sub(r"^v", "", ctx.release_version)
#     match = re.search(
#         rf"## v?\[?{version}[^\n]*\n(?P<notes>.+?)(\n##\s|\n### \[?[0-9]+\.|\Z)",
#         changelog,
#         re.DOTALL | re.MULTILINE,
#     )
#     if match is not None:
#         ctx.release_notes = match.group("notes").strip()
#     else:
#         ctx.release_notes = ""
# 
# def kokoro_job_name(upstream_repo: str, package_name: str) -> Union[str, None]:
#     """Return the Kokoro job name.
# 
#     Args:
#         upstream_repo (str): The GitHub repo in the form of `<owner>/<repo>`
#         package_name (str): The name of package to release
# 
#     Returns:
#         The name of the Kokoro job to trigger or None if there is no job to trigger
#     """
#     return f"cloud-devrel/client-libraries/nodejs/release/{upstream_repo}/publish"
# 
# def package_name(pull: dict) -> Union[str, None]:
#     return None
# 
# Path: releasetool/commands/common.py
# class TagContext(GitHubContext):
#     release_pr: Optional[dict] = None
#     release_tag: Optional[str] = None
#     release_version: Optional[str] = None
#     github_release: Optional[dict] = None
#     kokoro_job_name: Optional[str] = None
#     fusion_url: Optional[str] = None
#     token: Optional[str] = None


# Path: tests/commands/tag/test_tag_nodejs.py
from releasetool.commands.tag.nodejs import (
    _get_latest_release_notes,
    kokoro_job_name,
    package_name,
)
from releasetool.commands.common import TagContext

* adds a fancy new feature ([c46bfa3](https://www.github.com/bcoe/examples-conventional-commits/commit/c46bfa3))


### BREAKING CHANGES

* this fancy new feature breaks things
* disclaimer breaks everything"""
    ctx = TagContext(release_version="v2.0.0")
    _get_latest_release_notes(ctx, fixture_new_style_changelog)
    assert ctx.release_notes == expected


def test_extracts_appropriate_release_notes_when_prior_release_is_patch():
    """
    see: https://github.com/googleapis/release-please/issues/140
    """
    ctx = TagContext(release_version="v5.0.0")
    _get_latest_release_notes(ctx, fixture_new_style_patch)
    expected = """### ⚠ BREAKING CHANGES

* temp directory now defaults to setting for report directory

### Features

* default temp directory to report directory ([#102](https://www.github.com/bcoe/c8/issues/102)) ([8602f4a](https://www.github.com/bcoe/c8/commit/8602f4a))
* load .nycrc/.nycrc.json to simplify migration ([#100](https://www.github.com/bcoe/c8/issues/100)) ([bd7484f](https://www.github.com/bcoe/c8/commit/bd7484f))"""
    assert ctx.release_notes == expected


def test_kokoro_job_name():

    job_name = kokoro_job_name("upstream-owner/upstream-repo", "some-package-name")