-
Notifications
You must be signed in to change notification settings - Fork 52
feat: Implement git: provider #211
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
base: main
Are you sure you want to change the base?
Conversation
|
love the new impl! |
|
Any reason closing @tkesgar? |
|
Oh sorry, I was a bit emotional due to personal stuff a few days ago. I will work on the PR again once I have some time. The only thing remaining is to fix the tests and sync with the latest main branch (there are some changes on the |
|
Looks like the test job fails because of public key issues when cloning via git. From running the CI job with I think it should be possible to fix this by adding the github public key, but I want to try an alternative approach to use https URL instead. Update: I tried adding known_hosts but it does not seem to work. Therefore, I added some small change so we can use Git over HTTPS, and the tests are now using Git over HTTPS. For some reason it is much faster, I am not sure if GitHub has different behavior when cloning over HTTPS. |
|
Looks like Github Actions only retrieve a specific commit, so we cannot test clone with specific version reference in CI. I added |
Resolves #84
This PR allow giget to download using
git::Initially we added a new
gitfield inTemplateProvider. Based on the review feedback, we adjusted thetarinTemplateProviderto accept a function that returns Readable/ReadableStream for a tarfile:When giget receives a function instead of a string, giget will pipe the stream to the internal tar path (reuses the code from
download()). This way, we can move out most of the git handling to provider and reuse the existing tar handling (cache, extract subdirectory).Git handling logic is mostly in the
gitprovider now, with the logic to parse input is inparseGitCloneURIutility. It works similarly with package managers like npm/pnpm by callinggitcommand in shell, then pack it back into a tar and pass it as stream.We accept various kinds of URLs similar to what we can use in
package.json:[email protected]:unjs/template.git[email protected]:unjs/templategithub.com:unjs/templategithub:unjs/templategh:unjs/templateunjs/template(impliesgithub.com)gitlab:unjs/template(=>[email protected]:unjs/template)For custom git remote, use
GIGET_GIT_*variables:Specific ref is supported via hash:
github:unjs/template#main.I cannot find any existing convention for specific subdirectory, so I implemented it as
:after ref:github:unjs/template#main:src. Omitting the branch also works:github:unjs/template#:src.Local path is supported:
giget git:/path/to/local/repo(absolute),giget git:./local/repo(relative). However, this will allow users to clone any local repositories, so I put it behindGIGET_GIT_ALLOW_LOCALenvironment variable. I don't think there are a lot of use cases for this (probably useful for testing), but I am planning to explore this for personal purpose (cloning from a local gitea instance).HTTPS URL is supported:
giget git:https://github.com/unjs/template.git(notice thegit:prefix; otherwise giget will use its own URL handing). This feature relies on Git protocol itself. This is mainly added for testing purposes, but there may be people who want to use HTTPS URL.A minor chore change is to exclude
./test/.tmpfrom Vitest, since Vitest faithfully tries to run every tests from git repos we cloned 😅I think the implementation is mostly complete for now, but since we call some shell commands we probably want to test it a bit on Windows.