[git] Add gitCheckout
utility function
#68
Merged
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.
Closes #43
This PR adds a new
gitCheckout
utility function to thegit
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 (likegit-remote-https
, needed for cloning a repo over HTTPS)GIT_TEMPLATE_DIR
: A directory containing templates, e.g. when initializing an empty repo