Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitlab多层子项目url解析异常 #1239

Open
aak1247 opened this issue Oct 25, 2022 · 3 comments
Open

Gitlab多层子项目url解析异常 #1239

aak1247 opened this issue Oct 25, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@aak1247
Copy link

aak1247 commented Oct 25, 2022

Versions

  • dumi: 1.1.48
  • node: 16.13
  • npm: 8.1

Description

// process other case, protocol://domain/group/repo{discard remaining paths}
    repoUrl =
      repoUrl || url.replace(/^.*?((?:[\w-]+\.?)+)+[:/]([\w-]+)\/([\w-]+).*$/, 'https://$1/$2/$3');

preset-dumi中路径会被统一处理为两级子项目,但是gitlab支持多级subgroup,导致最终拼接的结果异常(只保留了前两集group),为什么不直接用传入的地址?

@aak1247 aak1247 added the bug Something isn't working label Oct 25, 2022
@aak1247 aak1247 closed this as completed Oct 25, 2022
@aak1247
Copy link
Author

aak1247 commented Oct 25, 2022

import hostedGit from 'hosted-git-info';

export default (url: any, platform?: 'gitlab') => { 
  if (!url || typeof(url) !== 'string') return '';

  let repoUrl = hostedGit.fromUrl(url)?.browse();

我以为这个代码能work,但是实际看下来,这个hostedGit.fromUrl()始终是undefined,那gitlab被异常就是就是应有之义了

@aak1247 aak1247 reopened this Oct 25, 2022
@aak1247 aak1247 closed this as completed Oct 25, 2022
@aak1247
Copy link
Author

aak1247 commented Oct 25, 2022

破案了,这个库hosted-git-info,对gitlab的支持并不好。
一个常见的scheme: git@gitlab.company.com/group/subgroup/project.git,它是会解析失败的。

相关:npm/hosted-git-info#54

@aak1247 aak1247 reopened this Oct 25, 2022
@ZN1996
Copy link
Contributor

ZN1996 commented Dec 9, 2022

破案了,这个库hosted-git-info,对gitlab的支持并不好。 一个常见的scheme: git@gitlab.company.com/group/subgroup/project.git,它是会解析失败的。

相关:npm/hosted-git-info#54

或许你可以自己在项目的依赖中指定hosted-git-info这个库用最新的版本,这样应该就能解决这个解析异常的问题了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants