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 subgroup results in "Unable to parse git host URL" error #90

Open
mitar opened this issue Dec 1, 2021 · 7 comments
Open

GitLab subgroup results in "Unable to parse git host URL" error #90

mitar opened this issue Dec 1, 2021 · 7 comments
Labels
pull request welcome A pull request is welcome

Comments

@mitar
Copy link

mitar commented Dec 1, 2021

When running inside a git clone which is using SSH git location.

@vweevers
Copy link
Owner

vweevers commented Dec 1, 2021

Which version of hallmark, and do you have an example?

@mitar
Copy link
Author

mitar commented Dec 1, 2021

Version 4.0.0. The full error is:

Error: Unable to parse git host URL "git@gitlab.com:tozd/go/errors.git"

It looks like it might be connected with the fact that I use sub-group on GitLab?

@vweevers
Copy link
Owner

vweevers commented Dec 1, 2021

I'm not familiar with GitLab sub-groups, but judging by that URL, I'd guess so, yes. Note that hallmark is currently geared towards GitHub so you may run into other issues too (just a heads up).

@vweevers
Copy link
Owner

vweevers commented Dec 1, 2021

Support of sub-groups is blocked on npm/hosted-git-info#54 which is used internally here.

@vweevers vweevers changed the title "Unable to parse git host URL" error GitLab subgroup results in "Unable to parse git host URL" error Jan 27, 2022
@vweevers vweevers added the blocked Unable to proceed with this issue or pull request label Jan 27, 2022
@dbrakman
Copy link

dbrakman commented Jan 4, 2023

Addressing OP's use case seems to work with hosted-git-info 6.1.1:

hostedGitInfo = requires("hosted-git-info")
hostedGitInfo.fromUrl("git@gitlab.com:tozd/go/errors.git")

I was able to use hallmark to autogenerate a draft changelog at my workplace for a repo that has a remote url like git@gitlab.com:company/department/team/subteam/project-collection/project.git with the following addition to a local installation of hallmark's package.json:

  "overrides": {
    "hosted-git-info": "6.1.1"
  },

It's a bit scattered, but it seems that gitlab subgroups were marked as supported upstream in hosted-git-info #56 and hosted-git-info #43 (though this commit is supposedly in version 3.0.8 with which I also had this issue)

The use case in the hosted-git-info #54 issue linked as a blocker of this one has the overriding problem of self-hosted gitlab, which has been claimed in hosted-git-info #23 and #11to be out of scope for "hosted git info" as URL conventions for self-hosted version control systems (VCS) are not necessarily discernible from the domain.

It seems like the dreaded Conventional Commits tool tried and failed to fall back to provided domains, but I like their moxie. If the possibility of generating broken VCS links could be nonfatal or skipped, enabling the autogeneration of draft changelogs for self-hosted enterprise VCS users could greatly broaden the scope of adoption of this standard. It'd still be a draft requiring human review, and the target audience likely has enough familiarity with regexes or find-and-replace to fix any broken links.

I'm pretty new to node, so for my benefit as much as anyone else's, the commands specifically used to demonstrate success are within:

export PATH_TO_LOCAL_HALLMARK='/path/to/hallmark'
export PATH_TO_MY_REPO='/path/to/myrepo'
git clone https://github.com/vweevers/hallmark.git $PATH_TO_LOCAL_HALLMARK
cd $PATH_TO_LOCAL_HALLMARK
printf '{
  "override": {
    "hosted-git-info": "6.1.1"
  },' > tmpfile
awk 'NR > 1 {print}' package.json >> tmpfile
mv tmpfile package.json
npm install --save-dev .
npm link
cd $PATH_TO_MY_REPO
chmod +x ~/homebrew/lib/node_modules/hallmark/compat/cli.cjs
hallmark cc init

Observe new, nonempty file at $PATH_TO_MY_REPO/CHANGELOG.md.

@koppor
Copy link

koppor commented Sep 8, 2023

I am using GitHub and get the same error:

> hallmark lint CHANGELOG.md
Error: Unable to find git host
    at parse (C:\Users\koppor\AppData\Roaming\npm\node_modules\hallmark\node_modules\find-githost\index.js:129:11)
    at exports.fromGit (C:\Users\koppor\AppData\Roaming\npm\node_modules\hallmark\node_modules\find-githost\index.js:110:10)
    at repo (file:///C:/Users/koppor/AppData/Roaming/npm/node_modules/hallmark/index.js:224:13)
    at hallmark (file:///C:/Users/koppor/AppData/Roaming/npm/node_modules/hallmark/index.js:29:22)
    at Module.lint (file:///C:/Users/koppor/AppData/Roaming/npm/node_modules/hallmark/index.js:153:10)
    at file:///C:/Users/koppor/AppData/Roaming/npm/node_modules/hallmark/cli.js:33:14
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

The issue is when using git worktree, when .git is a file and not I directory.

$ cat .git
gitdir: C:/git-repositories/jabref-all/jabref/.git/worktrees/jabref

@vweevers
Copy link
Owner

vweevers commented Sep 8, 2023

@koppor That's a separate issue. A PR is welcome over at https://github.com/vweevers/find-gitdir (which does support git-style symlinks, for support of submodules, but it may need something more to also support worktrees).

@vweevers vweevers added pull request welcome A pull request is welcome and removed blocked Unable to proceed with this issue or pull request labels Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull request welcome A pull request is welcome
Projects
None yet
Development

No branches or pull requests

4 participants