-
Notifications
You must be signed in to change notification settings - Fork 14
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
Specify git packages without branch name #207
Comments
Yes indeed, and this is a point that was raised by the r-opensci reviewers as well. However, the Nix Manual advises to specify the branch each time: https://nix.dev/manual/nix/2.22/language/builtins.html#builtins-fetchgit It is tedious, but I can understand their POV on this. |
Weird. The sha uniquely identifies the commit, so I don't understand why the need to specify the branch. Well, I guess I'll need to do some digging to get the branch of a particular commit. EDIT: After a bit of digging, it seems that the question of which branch a particular commit belongs to, technically doesn't make sense in git, although you can hack ways to get some answer. |
Ok, here's a very ugly and slow way of getting the branch name adapted from here. get_branch_name <- function(repo, sha) {
dir <- tempfile()
dir.create(dir)
old <- setwd(dir)
on.exit(setwd(old))
gitr::git("clone", repo, ".")
branch <- gitr::git("name-rev --refs=\"refs/heads/*\" --name-only", sha)$stdout
strsplit(branch, "~")[[1]][1]
} It is absolutely disgusting, but it works. |
thanks, but I think we'll stick to the recommended Nix way, at least for now |
Indeed. I was thinking that automatically getting the branch name might be needed to complete a migration helper from renv to nix (#5 ). |
we might indeed need to come back to this idea at that point |
I noticed that you need to specify the name of the branch and the sha in the
git_pkgs
argument. I think it should be possible to identify the commit without the name of the branch and only with the commit sha. For example, https://github.com/eliocamp/metR/archive/1dd5d391d5da6a80fde03301671aea5582643914.zip will get you the contents of a particular commit without needing to know the branch name.I'm coming up to this because I'm trying to recreate an environment recorded in renv, which doesn't record the branch name.
The text was updated successfully, but these errors were encountered: