-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat: Implement git: provider #211
Open
tkesgar
wants to merge
34
commits into
unjs:main
Choose a base branch
from
tkesgar:giget-git
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pi0
reviewed
Feb 5, 2025
pi0
reviewed
Feb 5, 2025
love the new impl! |
pi0
reviewed
Feb 5, 2025
pi0
reviewed
Feb 6, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #84
This PR allow giget to download using
git:
:Initially we added a new
git
field inTemplateProvider
. Based on the review feedback, we adjusted thetar
inTemplateProvider
to 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
git
provider now, with the logic to parse input is inparseGitCloneURI
utility. It works similarly with package managers like npm/pnpm by callinggit
command 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
:git@github.com:unjs/template.git
git@github.com:unjs/template
github.com:unjs/template
github:unjs/template
gh:unjs/template
unjs/template
(impliesgithub.com
)gitlab:unjs/template
(=>git@gitlab.com: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_LOCAL
environment 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).A minor chore change is to exclude
./test/.tmp
from 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.