\tikzstyle{commit}=[draw,circle,fill=white,inner sep=0pt,minimum size=5pt]
\tikzstyle{every path}=[draw]
\tikzstyle{branch}=[draw,rectangle,rounded corners=3,fill=white,inner sep=2pt,minimum size=5pt]
-\node[commit, black, fill=black] (ef9548d) at (0.0,0) {};
-\node[right,xshift=10] (label_ef9548d) at (ef9548d.east) {\verb!ef9548d: [doc] hooktest 2!};
-\node[commit, black, fill=black] (8024ece) at (0.0,-0.5) {};
-\node[right,xshift=10] (label_8024ece) at (8024ece.east) {\verb!8024ece: [doc] hook test!};
-\node[commit, black, fill=black] (8dde7ec) at (0.0,-1.0) {};
-\node[right,xshift=10] (label_8dde7ec) at (8dde7ec.east) {\verb!8dde7ec: [doc] neues Hooks!};
-\node[commit, black, fill=black] (53e02cf) at (0.0,-1.5) {};
-\node[right,xshift=10] (label_53e02cf) at (53e02cf.east) {\verb!53e02cf: [doc] test!};
-\node[commit, blue, fill=blue] (16d4f59) at (0.5,-2.0) {};
-\node[right,xshift=10] (label_16d4f59) at (16d4f59.east) {\verb!16d4f59: [doc] test!};
-\node[commit, black, fill=black] (6e41ab0) at (0.0,-2.5) {};
-\node[right,xshift=10] (label_6e41ab0) at (6e41ab0.east) {\verb!6e41ab0: [py] fixed order!};
-\node[commit, black, fill=black] (2256509) at (0.0,-3.0) {};
-\node[right,xshift=10] (label_2256509) at (2256509.east) {\verb!2256509: [py] fixed automatic colors!};
-\node[commit, black, fill=black] (8a5d531) at (0.0,-3.5) {};
-\node[right,xshift=10] (label_8a5d531) at (8a5d531.east) {\verb!8a5d531: [py] minor fix!};
-\node[commit, black, fill=black] (7ac7de4) at (0.0,-4.0) {};
-\node[right,xshift=10] (label_7ac7de4) at (7ac7de4.east) {\verb!7ac7de4: Merge branch 'master' into feature/python!};
-\node[commit, blue, fill=blue] (69be133) at (0.5,-4.5) {};
-\node[right,xshift=10] (label_69be133) at (69be133.east) {\verb!69be133: [py]minor bugfix!};
-\node[commit, black, fill=black] (1af283b) at (0.0,-5.0) {};
-\node[right,xshift=10] (label_1af283b) at (1af283b.east) {\verb!1af283b: [py] some comments!};
-\node[commit, black, fill=black] (da268ea) at (0.0,-5.5) {};
-\node[right,xshift=10] (label_da268ea) at (da268ea.east) {\verb!da268ea: [py] Export copy finished!};
-\node[commit, black, fill=black] (3dbbd41) at (0.0,-6.0) {};
-\node[right,xshift=10] (label_3dbbd41) at (3dbbd41.east) {\verb!3dbbd41: [py] commit & branch läuft!};
-\node[commit, black, fill=black] (afd6f5a) at (0.0,-6.5) {};
-\node[right,xshift=10] (label_afd6f5a) at (afd6f5a.east) {\verb!afd6f5a: [py] Commit funktioniert!};
-\node[commit, black, fill=black] (9ebee64) at (0.0,-7.0) {};
-\node[right,xshift=10] (label_9ebee64) at (9ebee64.east) {\verb!9ebee64: [py] init & git shell!};
-\node[commit, black, fill=black] (e5c3cd5) at (0.0,-7.5) {};
-\node[right,xshift=10] (label_e5c3cd5) at (e5c3cd5.east) {\verb!e5c3cd5: added Ruby Skript!};
-\node[commit, black, fill=black] (d78896f) at (0.0,-8.0) {};
-\node[right,xshift=10] (label_d78896f) at (d78896f.east) {\verb!d78896f: [doc] kleine änderrung!};
-\node[commit, black, fill=black] (a6f6d74) at (0.0,-8.5) {};
-\node[right,xshift=10] (label_a6f6d74) at (a6f6d74.east) {\verb!a6f6d74: Grober Latex Test!};
-\path[black] (8024ece) to[out=90,in=-90] (ef9548d);
+\node[commit, black, fill=black] (a6f6d74) at (0.0,0) {};
+\node[right,xshift=10] (labela6f6d74) at (a6f6d74.east) {\verb!a6f6d74: Grober Latex Test!};
+\node[commit, black, fill=black] (d78896f) at (0.0,0.5) {};
+\node[right,xshift=10] (labeld78896f) at (d78896f.east) {\verb!d78896f: [doc] kleine õnderrung!};
+\node[commit, black, fill=black] (e5c3cd5) at (0.0,1.0) {};
+\node[right,xshift=10] (labele5c3cd5) at (e5c3cd5.east) {\verb!e5c3cd5: added Ruby Skript!};
+\node[commit, black, fill=black] (9ebee64) at (0.0,1.5) {};
+\node[right,xshift=10] (label9ebee64) at (9ebee64.east) {\verb!9ebee64: [py] init & git shell!};
+\node[commit, black, fill=black] (afd6f5a) at (0.0,2.0) {};
+\node[right,xshift=10] (labelafd6f5a) at (afd6f5a.east) {\verb!afd6f5a: [py] Commit funktioniert!};
+\node[commit, black, fill=black] (3dbbd41) at (0.0,2.5) {};
+\node[right,xshift=10] (label3dbbd41) at (3dbbd41.east) {\verb!3dbbd41: [py] commit & branch lõuft!};
+\node[commit, black, fill=black] (da268ea) at (0.0,3.0) {};
+\node[right,xshift=10] (labelda268ea) at (da268ea.east) {\verb!da268ea: [py] Export copy finished!};
+\node[commit, black, fill=black] (1af283b) at (0.0,3.5) {};
+\node[right,xshift=10] (label1af283b) at (1af283b.east) {\verb!1af283b: [py] some! comments!};
+\node[commit, blue, fill=blue] (69be133) at (0.5,4.0) {};
+\node[right,xshift=10] (label69be133) at (69be133.east) {\verb!69be133: [py]minor bugfix!};
+\node[commit, black, fill=black] (7ac7de4) at (0.0,4.5) {};
+\node[right,xshift=10] (label7ac7de4) at (7ac7de4.east) {\verb!7ac7de4: Merge branch 'master' into feature/python!};
+\node[commit, black, fill=black] (8a5d531) at (0.0,5.0) {};
+\node[right,xshift=10] (label8a5d531) at (8a5d531.east) {\verb!8a5d531: [py] minor fix!};
+\node[commit, black, fill=black] (2256509) at (0.0,5.5) {};
+\node[right,xshift=10] (label2256509) at (2256509.east) {\verb!2256509: [py] fixed automatic colors!};
+\node[commit, black, fill=black] (6e41ab0) at (0.0,6.0) {};
+\node[right,xshift=10] (label6e41ab0) at (6e41ab0.east) {\verb!6e41ab0: [py] fixed order!};
+\node[commit, black, fill=black] (53e02cf) at (0.0,6.5) {};
+\node[right,xshift=10] (label53e02cf) at (53e02cf.east) {\verb!53e02cf: [doc] test!};
+\node[commit, black, fill=black] (8dde7ec) at (0.0,7.0) {};
+\node[right,xshift=10] (label8dde7ec) at (8dde7ec.east) {\verb!8dde7ec: [doc] neues Hooks!};
+\node[commit, black, fill=black] (8024ece) at (0.0,7.5) {};
+\node[right,xshift=10] (label8024ece) at (8024ece.east) {\verb!8024ece: [doc] hook test!};
+\node[commit, black, fill=black] (7ef61eb) at (0.0,8.0) {};
+\node[right,xshift=10] (label7ef61eb) at (7ef61eb.east) {\verb!7ef61eb: [doc] hooktest 2!};
+\node[commit, black, fill=black] (d477a13) at (0.0,8.5) {};
+\node[right,xshift=10] (labeld477a13) at (d477a13.east) {\verb!d477a13: [doc] neuer Branch!};
+\node[commit, blue, fill=blue] (d2bf877) at (0.5,9.0) {};
+\node[right,xshift=10] (labeld2bf877) at (d2bf877.east) {\verb!d2bf877: [py] new git order!};
+\node[commit, blue, fill=blue] (6b30984) at (0.5,9.5) {};
+\node[right,xshift=10] (label6b30984) at (6b30984.east) {\verb!6b30984: [py] 2new git order!};
+\node[commit, blue, fill=blue] (827f503) at (0.5,10.0) {};
+\node[right,xshift=10] (label827f503) at (827f503.east) {\verb!827f503: [doc] Features/Bugs [py] reversed changed!};
+\node[commit, blue, fill=blue] (0ee95d1) at (0.5,10.5) {};
+\node[right,xshift=10] (label0ee95d1) at (0ee95d1.east) {\verb!0ee95d1: [doc] Hook test!};
+\node[commit, blue, fill=blue] (0009b09) at (0.5,11.0) {};
+\node[right,xshift=10] (label0009b09) at (0009b09.east) {\verb!0009b09: [doc] Hook2 test!};
+\node[commit, blue, fill=blue] (494a6ba) at (0.5,11.5) {};
+\node[right,xshift=10] (label494a6ba) at (494a6ba.east) {\verb!494a6ba: [doc] Hook2 test!};
+\node[commit, blue, fill=blue] (ddec20f) at (0.5,12.0) {};
+\node[right,xshift=10] (labelddec20f) at (ddec20f.east) {\verb!ddec20f: [doc] lsting Hooks!};
+\node[commit, blue, fill=blue] (71f4986) at (0.5,12.5) {};
+\node[right,xshift=10] (label71f4986) at (71f4986.east) {\verb!71f4986: [py] better color function!};
+\node[commit, black, fill=black] (7c94d50) at (0.0,13.0) {};
+\node[right,xshift=10] (label7c94d50) at (7c94d50.east) {\verb!7c94d50: Merge branch 'develop' into feature/python2!};
+\node[commit, black, fill=black] (52b6561) at (0.0,13.5) {};
+\node[right,xshift=10] (label52b6561) at (52b6561.east) {\verb!52b6561: minor PyUpdate Fix Front parsing works basic!};
+\node[commit, black, fill=black] (cc9a3ca) at (0.0,14.0) {};
+\node[right,xshift=10] (labelcc9a3ca) at (cc9a3ca.east) {\verb!cc9a3ca: parsing for repo works!};
+\node[commit, black, fill=black] (769f9d1) at (0.0,14.5) {};
+\node[right,xshift=10] (label769f9d1) at (769f9d1.east) {\verb!769f9d1: new Hashing, resolve Parents works!};
+\path[black] (cc9a3ca) to[out=90,in=-90] (769f9d1);
+\path[black] (52b6561) to[out=90,in=-90] (cc9a3ca);
+\path[black] (7c94d50) to[out=90,in=-90] (52b6561);
+\path[blue] (71f4986) to[out=90,in=-90] (7c94d50);
+\path[blue] (ddec20f) to[out=90,in=-90] (71f4986);
+\path[blue] (494a6ba) to[out=90,in=-90] (ddec20f);
+\path[blue] (0009b09) to[out=90,in=-90] (494a6ba);
+\path[blue] (0ee95d1) to[out=90,in=-90] (0009b09);
+\path[blue] (827f503) to[out=90,in=-90] (0ee95d1);
+\path[blue] (6b30984) to[out=90,in=-90] (827f503);
+\path[blue] (d2bf877) to[out=90,in=-90] (6b30984);
+\path[black] (d477a13) to[out=90,in=-90] (7c94d50);
+\path[black] (7ef61eb) to[out=90,in=-90] (d2bf877);
+\path[black] (7ef61eb) to[out=90,in=-90] (d477a13);
+\path[black] (8024ece) to[out=90,in=-90] (7ef61eb);
\path[black] (8dde7ec) to[out=90,in=-90] (8024ece);
\path[black] (53e02cf) to[out=90,in=-90] (8dde7ec);
-\path[black] (6e41ab0) to[out=90,in=-90] (16d4f59);
\path[black] (6e41ab0) to[out=90,in=-90] (53e02cf);
\path[black] (2256509) to[out=90,in=-90] (6e41ab0);
\path[black] (8a5d531) to[out=90,in=-90] (2256509);
\path[black] (e5c3cd5) to[out=90,in=-90] (9ebee64);
\path[black] (d78896f) to[out=90,in=-90] (e5c3cd5);
\path[black] (a6f6d74) to[out=90,in=-90] (d78896f);
-\node[branch,right,xshift=10] (develop) at (label_ef9548d.east) {\lstinline{develop}};
-\node[branch,right,xshift=10] (feature/python) at (label_6e41ab0.east) {\lstinline{feature/python}};
-\node[branch,right,xshift=10] (master) at (label_16d4f59.east) {\lstinline{master}};
+\node[branch,right,xshift=10] (feature/python2) at (label769f9d1.east) {\lstinline{feature/python2}};
\end{tikzpicture}
+#!/usr/bin/python
+
from subprocess import check_output
from collections import OrderedDict
from re import compile, match
+from argparse import ArgumentParser
+import sys
# Importer fast fertig
# Aber die light Variante
linepat = compile(r'[^|\/\\]')
+#def print(line):
+# line = line.encode('utf-16LE')
+# sys.stdout.buffer.write(line)
def color(numb):
+ numb = int(numb)
colors = ["black", "blue", "brown", "cyan", "darkgray", "gray", "green", "lightgray", "lime", "magenta", "olive", "orange", "pink", "purple", "red", "teal", "violet", "white", "yellow"]
return colors[numb % colors.__len__()]
hashpat7 = compile(r"[a-f0-9]{7}")
hashpat40 = compile(r"[a-f0-9]{40}")
def __init__(self,hash):
- if Hash.hashpat7.match(hash) or hashpat40.match(hash):
+ if Hash.hashpat7.match(hash) or Hash.hashpat40.match(hash):
self._hash: str = hash
else:
raise ValueError('Wrong Hash Format')
for word in line.split(" "):
if self._message:
self._message += " " + word
- elif hashpat.match(word):
+ elif Hash.hashpat7.match(word):
if not self._hash:
self._hash = word
else:
child._children[self.hash()] = self
def export_to_tikz(self, ypos):
- print("\\node[commit, " + color(self._node_pos) + ", fill=" + color(self._node_pos) + "] (" + self._hash + ") at (" + str(.5 * self._node_pos) + "," + str(ypos) + ") {};")
- print("\\node[right,xshift=10] (label_" + self._hash + ") at (" + self._hash + ".east) {\\verb!" + self._hash + ": " + self._message + "!};")
+ print("\\node[commit, " + color(self._node_pos) + ", fill=" + color(self._node_pos) + "] (" + self.hash() + ") at (" + str(.5 * self._node_pos) + "," + str(ypos) + ") {};")
+ print("\\node[right,xshift=10] (label" + self.hash() + ") at (" + self.hash() + ".east) {\\verb!" + self.hash() + ": " + self._message.replace("\n"," ") + "!};")
#for child in self._children.itervalues():
- # print("\\path[" + "blue" +"] (" + self._hash + ") to[out=90,in=-90] (" + child._hash + ");")
+ # print("\\path[" + "blue" +"] (" + self.hash() + ") to[out=90,in=-90] (" + child.hash() + ");")
def __eq__(self,other):
return self.hash() == other.hash()
class Branch:
def __init__(self, line):
- self._hash=""
- words = line.split(" ")
+ words = line[2:].split(" ")
self._name = words.pop(0)
- while self._hash == "":
- self._hash = words.pop(0)
+ while words[0] == "":
+ words.pop(0)
+ self._hash = Hash(words.pop(0))
self._commit = " ".join(words)
+ def hash(self):
+ return self._hash.hash()
+
def to_s_long(self):
print("Name : " + self._name)
print("Hash : " + self._hash)
print(" ".join({self._name, self._hash, self._commit}))
class Repo:
-
def __init__(self):
self._commits = OrderedDict()
self._branches = []
else:
raise ValueError('Commit has no hash')
+ def add_commitlog(self,log):
+ for line in log.split("\n"):
+ if not line == "":
+
+ node_pos = -1
+ message_pos = -1
+
+ #Parse Graph
+ pos = 0
+ for c in line:
+ if c == '*':
+ node_pos = pos
+ elif linepat.match(c) and c != ' ':
+ message_pos = pos
+ break
+ pos = pos + 1
+
+ #Parse Msg
+ if node_pos >= 0: #new commit
+ com = line[message_pos:].split(' ')
+ if com[0] == 'commit':
+ comm = Commit(com[1:],node_pos*.5,message_pos)
+ self.add_commit(comm)
+ else:
+ raise ValueError('looks like a new commit but isn\'t: ' + line)
+ else: #still old commit
+ comm.AddInfo(line)
+ self.resolve_parents()
+
def resolve_parents(self):
for commit in self._commits.values():
for key_p in commit._parents.keys():
commit.update_parent(self._commits[key_p])
def add_branch(self, branch):
- if self._commits.has_key(branch._hash):
- branch._commit = self._commits[branch._hash]
- self._branches.append( branch)
+ if branch.hash() in self._commits:
+ branch._commit = self._commits[branch.hash()]
+ self._branches.append(branch)
def export_to_tikz(self):
print("\\begin{tikzpicture}")
for commit in self._commits.values():
for child in commit._children.values():
- print("\\path[" + color(commit._node_pos) +"] (" + commit._hash + ") to[out=90,in=-90] (" + child._hash + ");")
+ print("\\path[" + color(commit._node_pos) +"] (" + commit.hash() + ") to[out=90,in=-90] (" + child.hash() + ");")
for branch in self._branches:
- print("\\node[branch,right,xshift=10] (" + branch._name + ") at (label_" + branch._hash + ".east) {\\lstinline{" + branch._name +"}};")
+ print("\\node[branch,right,xshift=10] (" + branch._name + ") at (label" + branch.hash() + ".east) {\\lstinline{" + branch._name +"}};")
print("\\end{tikzpicture}")
+#parser = ArgumentParser()
+#parser.add_argument("-h", help="show this message", dest="help", default=True)
+#parser.add_argument("-o","--ofile", help="outputfile", dest="ofile", metavar="outputfile")
+
+#parser.add_argument("-f","--file",help="show history of one file", dest="hfile")
+#parser.add_argument("-a", help="show author", dest="author", default ="none", action="store_false")
+
+#args = parser.parse_args()
+
+
#new Repo
r = Repo()
# extract Commits
-cmd = "git log --branches --graph --parents"
+cmd = "git log --graph --parents"
return_output = check_output(cmd, shell=True, encoding='utf-8')
#print(return_output.split("\n"))
-comm = None
+#Fill Repo with commits
+r.add_commitlog(return_output)
-for line in return_output.split("\n"):
- if not line == "":
-
- node_pos = -1
- message_pos = -1
+# extract Branches
+cmd = "git branch -v" # | cut -b 3-"
- #Parse Graph
- pos = 0
- for c in line:
- if c == '*':
- node_pos = pos
- elif linepat.match(c) and c != ' ':
- message_pos = pos
- break
- pos = pos + 1
+return_output = check_output(cmd, shell=True, encoding='utf-8')
+#print(return_output.split("\n"))
- #Parse Msg
- if node_pos >= 0: #new commit
- com = line[message_pos:].split(' ')
- if com[0] == 'commit':
- comm = Commit(com[1:],node_pos,message_pos)
- r.add_commit(comm)
- else:
- raise ValueError('looks like a new commit but isn\'t: ' + line)
- else: #still old commit
- comm.AddInfo(line)
-
-r.resolve_parents()
+for line in return_output.split("\n"):
+ if not line == "":
+ r.add_branch(Branch(line))
-print(node_pos + message_pos)
+r.export_to_tikz()
\ No newline at end of file