Ask Your Question
2

What is the process for obtaining the hash of the most recent git commit of a Python package?

asked 2023-07-10 10:16:17 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-07-10 10:41:01 +0000

pufferfish gravatar image

To obtain the hash of the most recent git commit of a Python package, follow these steps:

  1. Navigate to the root directory of the package in your terminal or command prompt.
  2. Run the command git log -n 1. This will display the details of the most recent commit, including the hash.
  3. Look for the line that says "commit [hash]" and note down the hash value.

Alternatively, if you have the package installed locally on your machine and want to obtain the hash of the most recent commit of the installed version, you can run the following command in your terminal or command prompt:

pip show <package_name> | grep Version | awk '{print $2}' | xargs -I {} sh -c "echo {}; cat /path/to/site-packages/<package_name>.egg-info/GITSHA"

Replace <package_name> with the name of the Python package you want to obtain the hash for and replace /path/to/site-packages/ with the path to the directory where the package is installed on your machine. This command will display the version of the installed package followed by the hash of the most recent git commit.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-10 10:16:17 +0000

Seen: 12 times

Last updated: Jul 10 '23