In my Go project, I have a copy of https://github.com/HouzuoGuo/tiedot made locally. This was probably made manually (or go get) couple of years ago.
I cannot tell what version/tag was checked out since that is not maintained anywhere.
Is there any way for me to find the commit hash from hash of individual files? For example the some hashes are as below:
github.com/HouzuoGuo/tiedot/db> shasum *.go
79b42b7af9784255b39b4307950709880df4a86f col.go
b5f5a127c990229e8ac085eb8e7c72d0e6617e1c col_test.go
be45a7eae65803df2dc31e23db7eb27bcffa17cc db.go
290c32d11498aacb0456117f2bffa8e7ab74ccd8 db_test.go
3d0e0dc06fbd8191b5d68b32b4ac4200444e98f2 doc.go
f15745867ccfcb8609194b617cc6e8911174dad9 doc_test.go
40fcd698a680b39bd8405b9bc62d0f4b99411cbf idx_test.go
d1c481d7d75140b229440819bb21eb64095a7b35 query.go
c83114227dc59100de953ffceb4398e4d8a6075b query_test.go
Once I have commit has, I can add it to my go.mod file using something like go get github.com/HouzuoGuo/tiedot@<hash>
Based on suggestions from @torek below, I checked out the code from github and wrote a sample script to read all the commits and check if hash of one of the files matches. This does not work though. What am I missing?
COMMITS=$(git rev-list --all)
for COMMIT_HASH in $COMMITS
do
TREE_HASH=$(git cat-file -p $COMMIT_HASH | grep tree | cut -d' ' -f2)
if [[ -z "$TREE_HASH" ]]; then
echo "Tree hash is empty"
continue
fi
DB_DIR_HASH=$(git cat-file -p $TREE_HASH | grep '[[:space:]]db$' | awk '{print $3}')
if [[ -z "$DB_DIR_HASH" ]]; then
echo "db dir hash is empty"
continue
fi
DBGO_HASH=$(git cat-file -p $DB_DIR_HASH | grep db.go | awk '{print $3}')
if [[ -z "$DBGO_HASH" ]]; then
echo "db.go hash is empty"
continue
fi
if [[ "$DBGO_HASH" == "be45a7eae65803df2dc31e23db7eb27bcffa17cc" ]]; then
echo "db.go hash matched!!! Commit $COMMIT_HASH"
fi
done