-
Notifications
You must be signed in to change notification settings - Fork 761
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
Make sha work for shallow git copies #1048
Conversation
Thanks for looking into the problem and the fix. This actually will happen often in practice because travis does a shallow clone of the repository for every build. It would be great to have a test for this case, though I would prefer it be of a local git repository rather than a remote one. Could you also add a note to NEWS.md. |
@jimhester writing a test for this is not actually straight forward as git2r does not support creating shallow clones (e.g. ropensci/git2r#129). So the git repo to test against would have to be made another way, for example with the command line, or package a repo inside test? |
@jimhester also would the note go under 1.10.0.9000 in the bug fixes, thanks. |
Oops, I messed up the headings. Just put it directly under 1.10.0.9000 |
@nparley I would make a dummy package with a shallow checkout using command line git and put it in |
You'll probably need some trick with the I am not completely sure, but don't be surprised if it happens. |
Good point Gabor, an easy fix is to use a git clone --depth=50 --bare https://github.com/hadley/devtools.git /tmp/devtools
Rscript -e 'r <- git2r::repository("/tmp/devtools")' -e 'git2r::branch_target(git2r::head(r))'
[1] "21d5d9401101dcf2baada3db424e4de0e9c7f869" |
What @gaborcsardi says will definitely happen ( |
@jennybc I don't think that you can do this with |
@jennybc You can store .git with other names, see variety of answers at http://stackoverflow.com/questions/505467/can-i-store-the-git-folder-outside-the-files-i-want-tracked I even wrote a post about this a few years ago (http://www.jimhester.com/blog/2012/11/08/external-git/) although the solution there still has a .git file, so won't help here. |
I have added a test for the shallow clone repo and added a shallow bare copy into the testthat directory to test against. CMD check is now giving the note:
also the test pkg_sha <- git_sha1(path='testBareDepthRepo')
expect_equal(pkg_sha, '21d5d94011') assumes something of the path and so might not work in all situations? |
The nchar("devtools/tests/testthat/testBareDepthRepo/objects/pack/pack-c4e0f1d1d68408f260cbbf0a533ad5f6bfd5524e.idx")
#> [1] 104 renaming the testthat tests are run with You can remove all the sample hooks from |
OK that's solved the |
Can you please merge/rebase and squash? |
shallow git clones, i.e. git clones which make use of depth. (r-lib#1048, r-lib#1046, @nparley)
Done |
Thanks! |
Fix fetching the latest git commit so that it also works for shallow git copies (e.g. ropensci/git2r#219). Fixes #1046