Standard-version: repository url is no correct

Created on 14 Jan 2020  Â·  10Comments  Â·  Source: conventional-changelog/standard-version

$ standard-version --dry-run
✔ bumping version in package.json from 0.2.2 to 0.2.3
✔ outputting changes to CHANGELOG.md

---
### [0.2.3](https://git.llsapp.com///compare/v0.2.1...v0.2.3) (2020-01-14)


### Features

* umd ([90fadf3](https://git.llsapp.com///commit/90fadf3d012a8427af65fb1582a5b7983956d2ed))
* umd ([694c577](https://git.llsapp.com///commit/694c577f9bb55277df7ee57a581756f7290abaf9))
* umd ([18644ac](https://git.llsapp.com///commit/18644ac313e935e156b67236034a364bc49c5e29))
* umd ([2dc3517](https://git.llsapp.com///commit/2dc3517bd86efcb89d4a0d1c52eebb08ba271745))


### Bug Fixes

* using idlize module and compile it ([a70c8ba](https://git.llsapp.com///commit/a70c8ba3d49f5c0298954e08cc56eaf27cb69bcd))
---

✔ committing package.json and CHANGELOG.md
✔ tagging release v0.2.3
ℹ Run `git push --follow-tags origin fix/idlize && npm publish` to publish

try to config it through standard-verison in package.json. not woking.

needs more information question

Most helpful comment

To put it otherwise:

Conventional changelog should provide a way to support urls where user and project can be anywhere as part of the path url (e.g. https://git.some.corporate.domain.tld/scm/b2e/b2e-rwc.git).

It seems that the package @hutson/parse-repository-url cannot cope with that use case.
To be more precisely: I think @hutson/parse-repository-url splits only at the last slash (/) in the pathname, and everything before that will be considered to be the user which is not always correct.

Maybe it would help if one could specify the format of the repository like this (directly in package.json)?

"repository": {
    "url": "https://git.some.corporate.domain.tld/scm/b2e/b2e-rwc.git"
    "format": "http://{{domain}}/scm/{{user}}/{{project}}.git"
  }

or (taking precedence over "format" property):

"repository": {
    "url": "https://git.some.corporate.domain.tld/scm/b2e/b2e-rwc.git"
    "domain": "git.some.corporate.domain.tdl",
    "user": "b2e",
    "project": "b2e-rwc"
  }

In any of these cases, where either format, or any of domain, user, project are present in the repository field of package.json, the standard logic from @hutson/parse-repository-url should be ignored.

What do you think?

All 10 comments

Hi @lili21! To better help troubleshoot your issue, could you provide:

  • The output of standard-version --version
  • Your standard-version configuration.

It'd also be worth verifying (and providing) the value of the repository property in your package.json. It's possible this is an issue with the preset _or_ the CHANGELOG generator...

Here you go

$ standard-version --version
7.0.1
// package.json
...
"repository": {
    "type": "git",
    "url": "https://git.llsapp.com/client-infra/thanos/thanos-web.git"
  },
...

more information. it worked at first. but I transferred the repo, so I updated the git URL. After that, it never works.

i get the same error.

package url is handled in https://github.com/conventional-changelog/get-pkg-repo, which is just a wrapper of @hutson/parse-repository-url and hosted-git-info. you should probably look into them.

C:\Users\Administrator>standard-version -v
7.1.0

Same error when I use port in url.

 "repository": {
    "type": "git",
    "url": "http://git.xxxx.com:3000/yyy/zzz.git"
  }

the output :

http://git.xxxx.com:3000///commit/47c3de2b0cec58f198b1d721adec816ec7408715

@stevemao
but get-pkg-repo package.json work correct

G:\work\xxxxx>get-pkg-repo package.json
{
  browse: [Function (anonymous)],
  domain: 'git.xxxx.com:3000',
  project: 'zzz',
  type: null,
  user: 'yyy'
}

And when i use conventional-changelog,it is ok too

conventional-changelog -p angular -i CHANGELOG.md -s -r 0

if remove the port info, standard-version output will be ok

 "repository": {
    "type": "git",
    "url": "http://git.xxxx.com/yyy/zzz.git"
  }

the output :

http://git.xxxx.com/yyy/zzz/commit/47c3de2b0cec58f198b1d721adec816ec7408715
standard-version -v
7.1.0

Works:

"repository": {
    "url": "http://git.xxxx.com/yyy/zzz.git"
  }

Do not works (because of /xxx):

"repository": {
    "url": "http://git.xxxx.com/xxx/yyy/zzz.git"
  }

To put it otherwise:

Conventional changelog should provide a way to support urls where user and project can be anywhere as part of the path url (e.g. https://git.some.corporate.domain.tld/scm/b2e/b2e-rwc.git).

It seems that the package @hutson/parse-repository-url cannot cope with that use case.
To be more precisely: I think @hutson/parse-repository-url splits only at the last slash (/) in the pathname, and everything before that will be considered to be the user which is not always correct.

Maybe it would help if one could specify the format of the repository like this (directly in package.json)?

"repository": {
    "url": "https://git.some.corporate.domain.tld/scm/b2e/b2e-rwc.git"
    "format": "http://{{domain}}/scm/{{user}}/{{project}}.git"
  }

or (taking precedence over "format" property):

"repository": {
    "url": "https://git.some.corporate.domain.tld/scm/b2e/b2e-rwc.git"
    "domain": "git.some.corporate.domain.tdl",
    "user": "b2e",
    "project": "b2e-rwc"
  }

In any of these cases, where either format, or any of domain, user, project are present in the repository field of package.json, the standard logic from @hutson/parse-repository-url should be ignored.

What do you think?

I have created a pull request with @NicBright's proposal. This is a blocking feature for us as we don't use user repositories and have groups with sub-groups in our self-hosted gitlab environment.

Howdy, I am the maintainer of @hutson/parse-repository-url.

@lili21 reported an issue with the https://git.llsapp.com/client-infra/thanos/thanos-web.git URL.

Using @hutson/parse-repository-url I get:

> parser('https://git.llsapp.com/client-infra/thanos/thanos-web.git')
{
  browse: [Function (anonymous)],
  domain: 'git.llsapp.com',
  project: 'thanos-web',
  type: null,
  user: 'client-infra/thanos'
}

This _appears_ correct to me. The client-infra/thanos segment of the URL is treated as the user.

I do not know why this would cause standard-version to generate URLs like https://git.llsapp.com///commit/90fadf3d012a8427af65fb1582a5b7983956d2ed.

@alaingiller reported a similar issue with a repository URL containing multiple segments before the project name (http://git.xxxx.com/xxx/yyy/zzz.gi).

@xtutu reported an issue with the http://git.xxxx.com:3000/yyy/zzz.git URL.

Using @hutson/parse-repository-url I get:

> parser('http://git.xxxx.com:3000/yyy/zzz.git')
{
  browse: [Function (anonymous)],
  domain: 'git.xxxx.com:3000',
  project: 'zzz',
  type: null,
  user: 'yyy'
}

The port number is included as part of the domain property.

Also, as pointed out by @xtutu, this appears to work as expected when using get-pkg-repo and conventional-changelog.

I do not know why this would cause standard-version to generate invalid URLs.

Can someone please help me understand what standard-version is expecting from get-pkg-repo and @hutson/parse-repository-url that has caused invalid URLs to be generated?

Was this page helpful?
0 / 5 - 0 ratings