find all blob in a repo

This commit is contained in:
zy 2022-08-01 22:25:07 +08:00
parent 0c7d9ecdb9
commit 57f925ef37
3 changed files with 31 additions and 1 deletions

View File

@ -1,4 +1,4 @@
[settings]
line_length = 79
multi_line_output = 3
known_third_party =
known_third_party =dulwich

29
loadBlob.py Normal file
View File

@ -0,0 +1,29 @@
from dulwich.repo import Repo
def loadBlobObjects(dir):
"""
function: Find all blob objects in a given repo and make a list
input: the directory of a repo
output: a list of blob object
"""
repo = Repo(dir)
objectlist = list(repo.object_store)
bloblist = []
for object in objectlist:
if (
repo.object_store[object].type == 3
): # type == 1 -> commit; type == 2 -> tree ;type == 3 -> blob.
bloblist.append(repo.object_store[object].data)
repo.close()
return bloblist
def changeToSourceCode(list):
# TODO:转换成源代码文件或者是其他的能被克隆检测工具检测的形式,不知道该做成啥样就先放着
return 0
# a test for local repo
# list = loadBlobObjects("C:/Users/Administrator/redis")
# print(list)

View File

@ -1 +1,2 @@
pre-commit==2.20.0
dulwich==0.20.45