How to get commit hash in Pkg3?

With the old package manager, I could go into the package directory and do a git status or something similar to find out which commit I was on. How do I do this with Pkg3? While ]st does print a hash next to each package, I can’t figure out what it is (it doesn’t appear to be the git commit hash). It does also print the package version/tag, but if the package is tracking master then I’m unable to actually figure out which commit its on. Thanks.

Packages are not tracked by their commit hash but by their tree hash (which is a content hash, not a “history hash”). This means that the Manifest will still work even if someone rebases their branch.

But a convenience function to get the current commit SHA for the tree SHA is probably a good idea.

6 Likes

Thanks, yea I think that would be useful. FWIW, the situation I’m in is that I had done an add CodeTools#julia-0.7. A few days later there’s some new commits, so I did up CodeTools which did print me this line: [53a63b46] ~ CodeTools v0.5.0+ #julia-0.7 [https://github.com/JunoLab/CodeTools.jl.git], but left wondering whether I had actually gotten those new commits. (checking by hand the contents of the files in the package dir verified that I had, but obviously it’d be nicer to have an easy way to double check git commit).

Might be nice also to have a convenience function that went from Julia commit hash to the Julia version string
(yes, I know there is a script that does it - but I always have to search to find where it is :grinning: )

To go from the SHA hash to a commit, use

git log --pretty=raw | grep -B 2 <the-SHA-hash>
4 Likes