Skip to content

parseChangelog misses PR links when repoUrl has a trailing .git suffix #126

Open
MetaMask/auto-changelog
#298

Description

@omerbek

What happened?

parseChangelog({ shouldExtractPrLinks: true }) fails to extract long-form PR links when the repoUrl argument includes a trailing .git suffix.

That suffix is common in package.json repository URLs, including this package's own repository metadata:

"repository": {
  "type": "git",
  "url": "https://github.com/MetaMask/auto-changelog.git"
}

The parser derives repoName with extractRepoName(repoUrl), then embeds that value in the regex used to match PR links. Today, extractRepoName('https://github.com/MetaMask/auto-changelog.git') returns auto-changelog.git, but real GitHub PR URLs are shaped like /MetaMask/auto-changelog/pull/123, without .git. As a result, valid PR links are silently ignored.

Minimal reproduction

const changelog = parseChangelog({
  changelogContent: `# Changelog

## [Unreleased]

## [1.0.0]
### Changed
- Fix something ([#123](https://github.com/MetaMask/auto-changelog/pull/123))

[Unreleased]: https://github.com/MetaMask/auto-changelog/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/MetaMask/auto-changelog/releases/tag/v1.0.0`,
  repoUrl: 'https://github.com/MetaMask/auto-changelog.git',
  shouldExtractPrLinks: true,
});

changelog.getReleaseChanges('1.0.0');

Expected: the change has prNumbers: ['123'] and the description no longer includes the PR link.

Actual: the PR link is left in the description and prNumbers is empty.

Suggested fix

Strip an optional trailing .git inside extractRepoName() itself, instead of relying on all callers to normalize repoUrl before calling parseChangelog().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions