standard-version: Changelog links are incorrect for selfhosted gitlab (default setup) since 6.0.0

This is not a duplicate of #204. We have standard self-hosted Gitlab server running.

With 5.0.2 we get this output on an fresh repo with npm init and adding standard-version@5.0.2 only:

./node_modules/.bin/standard-version --dry-run
✔ bumping version in package.json from 1.0.0 to 1.1.0
✔ bumping version in package-lock.json from 1.0.0 to 1.1.0
✔ created CHANGELOG.md
✔ outputting changes to CHANGELOG.md

---
# 1.1.0 (2019-06-17)


### Bug Fixes

* remove node_modules ([613feb1](https://gitlab.company.net/myusername/changelogtest/commit/613feb1))


### Features

* add inital npm setup ([9d33dfb](https://gitlab.company.net/myusername/changelogtest/commit/9d33dfb))
* add standard-version v5.0.2 ([a09dc1c](https://gitlab.company.net/myusername/changelogtest/commit/a09dc1c))
---

After installing 6.0.0 (or 6.0.1) like this:

npm i standard-version@6.0.0

We now get broken links:

./node_modules/.bin/standard-version --dry-run
✔ bumping version in package.json from 1.0.0 to 1.1.0
✔ bumping version in package-lock.json from 1.0.0 to 1.1.0
✔ created CHANGELOG.md
✔ outputting changes to CHANGELOG.md

---
## 1.1.0 (2019-06-17)


### Bug Fixes

* remove node_modules ([613feb1](https://gitlab.company.net///commit/613feb1))


### Features

* add inital npm setup ([9d33dfb](https://gitlab.company.net///commit/9d33dfb))
* add standard-version v5.0.2 ([a09dc1c](https://gitlab.company.net///commit/a09dc1c))
---

I know 6.0.0 introduced breaking changes but I couldn’t find something related to this after skimming over the commits and changes since 5.0.2.

Do you have any idea or tipps in what direction I could research?
This issue only appears with a self-hosted Gitlab instance. I tried the same with a repo from the public Github and Gitlab services and both work. I’m confused.

Update:
Another thing I noticed. Using conventional-changelog-cli the changelog is being generated correctly.

./node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s -r 0
cat CHANGELOG.md

CHANGELOG.md:

# 1.0.0 (2019-06-18)


### Bug Fixes

* remove node_modules ([613feb1](https://gitlab.company.net/myusername/changelogtest/commit/613feb1))


### Features

* add inital npm setup ([9d33dfb](https://gitlab.company.net/myusername/changelogtest/commit/9d33dfb))
* add standard-version v5.0.2 ([a09dc1c](https://gitlab.company.net/myusername/changelogtest/commit/a09dc1c))

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 15
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I have identified the issue. It occurs in this deeply nested NPM dependency: hosted-git-info. I encountered the same issue. I opened an Issue in their repo. Maybe a maintainer of Standard Version could help by opening an MR to them, or using a different dependency?

https://github.com/npm/hosted-git-info/issues/54

Dependency chain of the issue is:

standard-version changelog.js -> conventional-changelog index.js -> conventional-changelog-core merge-config.js -> get-pkg-repo index.js -> hosted-git-info index.js

I actually have no idea where to report this issue since it goes so deep. Essentially, all along the way, a GitHub URL is being assumed. Gitlab allows subgroups and this totally breaks the repository url parsing code. This is not a user issue at all – the code doesn’t even handle the case gracefully. Instead you end up with that triple /// in your CHANGELOG url because the tooling returns a null string in the config needed by conventional-changelog-conventionalcommits package.

conventional-changelog-angular\templates\header.hbs references properties like,

which all are null because of the failure to parse.

As a workaround, you can create a file called .versionrc at the root of your project with:

{
  "types":[
    {
      "type":"enh",
      "section":"Enhancements"
    },
    {
      "type":"feat",
      "section":"Features"
    },
    {
      "type":"fix",
      "section":"Bug Fixes"
    },
    {
      "type":"test",
      "section":"Tests"
    },
    {
      "type":"build",
      "section":"Build System"
    },
    {
      "type":"ci",
      "hidden":true
    },
    {
      "type":"git",
      "hidden":true
    }
  ],
  "commitUrlFormat": "https://xxx/yyy/commit/{{hash}}",
  "compareUrlFormat": "https://xxx/yyy/compare/{{previousTag}}...{{currentTag}}",
  "issueUrlFormat": "https://xxx/yyy/issues/{{id}}",
  "userUrlFormat": "https://xxx/gitlab/{{user}}"
}

Where xxx is the URL to your gitlab and yyy the path to the project.