Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import zlib
- import graphviz
- def clearMessage(message):
- return message.decode()
- def clearParents(dt):
- return [parent.split(b" ")[-1].decode() for parent in dt if parent.startswith(b"parent")]
- def deserialize(data):
- dt = data.split(b"\n")
- dt.remove(b"")
- dt.remove(b'')
- roughMessage = dt[-1]
- parents = clearParents(dt)
- message = clearMessage(roughMessage)
- return [parents, message]
- def buildGraph(way, graph):
- digraph = graphviz.Digraph(comment='Git Log for {way}')
- digraph.attr('node', shape='octagon')
- for node in graph:
- for parent in node[1]:
- digraph.edge(parent, node[0], label=node[2])
- digraph.render('{way}.gv', view=True)
- unpack = zlib.decompressobj()
- graph = []
- way = "C:\\Users\\selebry\\test_repository\\.git\\objects"
- os.chdir(way)
- for path, directories, files in os.walk("."):
- if files !=0:
- for file in files:
- with open(path + "\\" + file, "rb") as f:
- data = zlib.decompress(f.read())
- if data[:6] == b"commit":
- commit_id = path[-2:] + file
- parents, message = deserialize(data)
- graph.append([commit_id, parents, message])
- f.close()
- os.chdir("C:\\Users\\selebry\\Desktop")
- buildGraph(way,graph)
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement