Render graph
This commit is contained in:
parent
2362d69673
commit
b854b4fa18
19
ugit/cli.py
19
ugit/cli.py
@ -1,4 +1,5 @@
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
@ -110,14 +111,24 @@ def tag(args):
|
||||
|
||||
|
||||
def k(args):
|
||||
dot = "digraph commits {\n"
|
||||
|
||||
oids = set()
|
||||
for refname, ref in data.iter_refs():
|
||||
print(refname, ref)
|
||||
dot += f"'{refname}' [shape=note]\n"
|
||||
dot += f"'{refname}' -> '{ref}'\n"
|
||||
oids.add(ref)
|
||||
|
||||
for oid in base.iter_commits_and_parents(oids):
|
||||
commit = base.get_commit(oid)
|
||||
print(oid)
|
||||
dot += f"'{oid}' [shape=box style=filled label='{oid[:10]}']\n"
|
||||
if commit.parent:
|
||||
print("Parent", commit.parent)
|
||||
# TODO visualize refs
|
||||
dot += f"'{oid}' -> '{commit.parent}'\n"
|
||||
|
||||
dot += "}"
|
||||
print(dot)
|
||||
|
||||
with subprocess.Popen(
|
||||
["dot", "-Tgtk", "/dev/stdin"], stdin=subprocess.PIPE
|
||||
) as proc:
|
||||
proc.communicate(dot.encode())
|
||||
|
Loading…
Reference in New Issue
Block a user