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

[git] Add gitCheckout utility function #68

Merged
merged 2 commits into from
Jul 15, 2024
Merged

[git] Add gitCheckout utility function #68

merged 2 commits into from
Jul 15, 2024

Conversation

kylewlacy
Copy link
Member

@kylewlacy kylewlacy commented Jul 15, 2024

Closes #43

This PR adds a new gitCheckout utility function to the git package. It takes a repository URL and a commit hash, and returns a recipe with the repo checked out with just that one commit. As mentioned in #43, this was based on the technique described in this article: https://blog.hartwork.org/posts/clone-arbitrary-single-git-commit/

The commit hash is validated to be a 40-character hex string to ensure that it's a full commit hash. This will prevent cloning from a branch/tag (which could change over time) or from a short commit hash (which could be ambiguous as more commits are added to the upstream repo).

Also, I updated the git package to set some environment variables that needed to be set to use git within Brioche (within the gitCheckout function specifically):

  • GIT_EXEC_PATH: Used to find the paths to some built-in git commands (like git-remote-https, needed for cloning a repo over HTTPS)
  • GIT_TEMPLATE_DIR: A directory containing templates, e.g. when initializing an empty repo

@kylewlacy kylewlacy merged commit 27631d3 into main Jul 15, 2024
3 checks passed
@kylewlacy kylewlacy deleted the git-checkout branch July 15, 2024 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Git package
1 participant