Skip to content

Support subgroup repository in shortcut syntax #268

Open
@wuiyang

Description

@wuiyang

Environment

Node: 20.16.0
NPM: 10.8.1
Changelogen: 0.6.1
Environment: Docker Ubuntu

Reproduction

Repoduction Steps

  1. In package.json, provide subgroup repository shortcut syntax
{
  "repository": "gitlab:group/subgroup-a/subgroup-a1/repo.git"
}
  1. Run npx changelogen and check the generated changelog

Expectation

It should generate changelog with link to commit.


## ...main

### 🤖 CI

- Added changelogen ([7b0990a](https://gitlab.com/group/subgroup-a/subgroup-a1/repo/commit/7b0990a))

### ❤️ Contributors

- Wuiyang Tan <[email protected]>

Actual result

The generated changelog did not includes link to commit.


## ...main

### 🤖 CI

- Added changelogen (7b0990a)

### ❤️ Contributors

- Wuiyang Tan <[email protected]>

More Information

I just tried with normal git repo link without shortcut syntax (https://gitlab.com/group/subgroup-a/subgroup-a1/repo), it work as expected.

Describe the bug

In repo with package.json using repository shortcut syntax, it cannot handle subgroup repository link correctly (gitlab:group/subgroup-a/subgroup-a1/repo.git)

The current regex for picking up the repository shortcut syntax only supports format [provider]:[owner]/[repo-name](.git)? without extra / in repo-name.

https://github.com/unjs/changelogen/blob/17ce7c7406bd2d8c14a9abf350977a4363ee3dc0/src/repo.ts#L41C1-L42C97

I believe updating the regex to accept optional / in repo-name section should be sufficient in picking up subgroups (and nested subgroups) repository.

// https://regex101.com/r/NA4Io6/1
const providerURLRegex =
-   /^(?:(?<user>[\w-]+)@)?(?:(?<provider>[^/:]+):)?(?<repo>[\w-]+\/(?:\w|\.(?!git$)|-)+)(?:\.git)?$/;
+   /^(?:(?<user>[\w-]+)@)?(?:(?<provider>[^/:]+):)?(?<repo>[\w-]+\/(?:\/?\w|\.(?!git$)|-)+)(?:\.git)?$/;

Included regex101 link for testing: https://regex101.com/r/Cmuakg/1

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions