python - How can I know which commit was used when installing a pip package from git? -


if install package git using https://pip.pypa.io/en/stable/reference/pip_install/#git specific commit checked out logged somewhere?

you use knittl's idea find nearest commit -- modification below address fact comparing git tree installed package, not git repository:

since installed package may lack of directory structure of git repository, make new directory git repo. i'll use html5lib example:

mkdir ~/tmp/html5lib cd ~/tmp/html5lib/ git init 

now fetch git tree:

git remote add foreign https://github.com/html5lib/html5lib-python git fetch foreign 

copy installed package git repo:

rsync -a ~/.virtualenvs/muffy/lib/python3.4/site-packages/html5lib ~/tmp/html5lib/ 

run git diff compare current state of repo (with installed package's code) each revision in git tree:

for rev in $(git rev-list --all);     echo $(git diff --shortstat foreign/master $rev) $rev ; done | sort -n 

this sorts number of files changed, number of insertions, deletions. output this:

1 file changed, 3 insertions(+), 1 deletion(-) 17499b9763a090f7715af49555d21fe4b558958b 2 files changed, 10 insertions(+), 8 deletions(-) ec674a97243e76da43f06abfd0a891308f1ff801 3 files changed, 17 insertions(+), 12 deletions(-) 1a28d721091a2c433c6e8471d14cbb75afd70d1c 4 files changed, 18 insertions(+), 13 deletions(-) ff6111cd82191a2eb963d6d662c6da8fa2e7ddde 6 files changed, 19 insertions(+), 19 deletions(-) ea0fafdbff732b1272140b696d6948054ed1d6d2 

the last item on each line associated git commit.

if git history long you'll want modify git rev-list --all range of commits. example, use git rev-list tag1..tag2 search between 2 tags. if know approximately when package installed, might have guess tags use. use git tag show names of possible tags. see the docs more options.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -