-
Notifications
You must be signed in to change notification settings - Fork 40
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
parseGitURI is not working for repositories in sub directory #148
Comments
We're using groups in gitlab and are experiencing the same issue. I've been able to (albeit nasty, by copying some code) to provide for our own specific use case, it may be crude but it works for now. The original idea I had was to call the provided gitlab TemplateProvider and override properties on the object where necessary, but as they are not exported I had to resort to copying it. I've also tried naming it as an other provider entirely but that didn't seem to get picked up. /**
* Handles the parsing of gitlab repo's with groups,
* does not work with nested branches in return as it assumes any slash after # is going to be the sub dir
*
* Copied from built-in giget gitlab TemplateProvider
* @see node_modules/giget/dist/index.cjs
* @see node_modules/giget/dist/index.mjs
* */
const groupedGitlab: TemplateProvider = async (input, options) => {
const gitlab = process.env.GIGET_GITLAB_URL || "https://gitlab.com";
const [repo, refWithPath = 'main'] = input.split('#');
const [ref, subDir = '/'] = refWithPath.split('/');
return {
name: repo.replace("/", "-"),
version: ref,
subdir: subDir,
headers: {
authorization: options.auth ? `Bearer ${options.auth}` : void 0,
// https://gitlab.com/gitlab-org/gitlab/-/commit/50c11f278d18fe1f3fb12eb595067216bb58ade2
"sec-fetch-mode": "same-origin"
},
url: `${gitlab}/${repo}/tree/${ref}${subDir}`,
tar: `${gitlab}/${repo}/-/archive/${ref}.tar.gz`
};
}; import {groupedGitlab} from "./template-providers/grouped-gitlab";
export default defineNuxtConfig({
extends: [
['gitlab:technology/nuxt-layers/example-layer', {
giget: {
providers: {
gitlab: groupedGitlab
},
}
}]
],
}); Did not properly test with subDir and refs, just wanted to share with you and others, what I came up with whilst trying to work around the same issue. |
Could be related to issue with RegEx |
Modified @JvanderHeide's solution to work with sub-groups in my case org/subgroup/repo import type { TemplateProvider } from 'giget'
/**
* Handles the parsing of GitLab repos with nested groups.
* Supports repositories within multiple group levels while maintaining
* proper branch and subdirectory handling.
*
* Example inputs:
* - org/repo
* - org/subgroup/repo
* - org/subgroup/repo#branch
* - org/subgroup/repo#branch/subdir
*
*/
export const groupedGitlab: TemplateProvider = async (input, options) => {
const gitlab = process.env.GIGET_GITLAB_URL || 'https://gitlab.com'
// Split into repo path and reference/subdir part
const [repoPath, refWithPath = 'main'] = input.split('#')
const [ref, subDir = '/'] = refWithPath.split('/')
// Handle the full repository path including groups
const encodedRepoPath = repoPath
.split('/')
.map(segment => encodeURIComponent(segment))
.join('/')
return {
// Use the last part of the repo path as the name
name: repoPath.split('/').pop() || '',
version: ref,
subdir: subDir,
headers: {
authorization: options.auth ? `Bearer ${options.auth}` : undefined,
'sec-fetch-mode': 'same-origin'
},
url: `${gitlab}/${encodedRepoPath}/tree/${ref}${subDir === '/' ? '' : '/' + subDir}`,
tar: `${gitlab}/${encodedRepoPath}/-/archive/${ref}/${repoPath.split('/').pop()}-${ref}.tar.gz`
}
} |
Hi :) Let's say we have a repository name within a directory in GitLab, such as
xxx/dir/website-1#master
. The regular expression you are using here is not working for this type of repository name.giget/src/_utils.ts
Line 49 in 83eb734
resulting:
"url": "https://git.xxx.com/xxx/dir/tree/master/website-1",
and should be
"url": "https://git.xxx.com/xxx/dir/website-1/tree/master/website-1-master.tar.bz"
The text was updated successfully, but these errors were encountered: