hashpat = re.compile(r"[a-f0-9]{7}")
linepat = re.compile(r'[^|\/\\]')
+colors = ["black", "blue", "brown", "cyan", "darkgray", "gray", "green", "lightgray", "lime", "magenta", "olive", "orange", "pink", "purple", "red", "teal", "violet", "white", "yellow"]
+
class Commit:
def __init__(self,line):
self._line = None
self._message_pos = pos
pos = pos + 1
+ self._message = self._message.replace("!","")
+
def update_parent (self, child):
self._parents[child._hash] = child
child._children[self._hash] = self
def export_to_tikz(self, ypos):
- print("export Commit:")
-
-
-
-
+ print("\\node[commit, " + "blue" + ", fill=" + "blue" + "] (" + 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 + "!};")
+ for child in self._children.itervalues():
+ print("\\path[" + "blue" +"] (" + self._hash + ") to[out=90,in=-90] (" + child._hash + ");")
class Branch:
def __init__(self, line):
self._hash=""
branch._commit = self._commits[branch._hash]
self._branches.append( branch)
-cmd = "git log --graph --oneline --parents"
+ def export_to_tikz(self):
+ print("\\begin{tikzpicture}")
+ print("\\tikzstyle{commit}=[draw,circle,fill=white,inner sep=0pt,minimum size=5pt]")
+ print("\\tikzstyle{every path}=[draw]")
+ print("\\tikzstyle{branch}=[draw,rectangle,rounded corners=3,fill=white,inner sep=2pt,minimum size=5pt]")
+ ypos = 0
+ ystep = -.5
+ for key_c,commit in self._commits.iteritems():
+ commit.export_to_tikz(ypos)
+ ypos = ypos + ystep
+
+ for branch in self._branches:
+ print("\\node[branch,right,xshift=10] (" + branch._name + ") at (label_" + branch._hash + ".east) {\\lstinline{" + branch._name +"}};")
+ print("\\end{tikzpicture}")
-return_output = check_output(cmd, shell=True)
-#print(return_output.split("\n"))
+# new REPO
r = Repo()
+# extract Commits
+cmd = "git log --graph --oneline --parents"
+
+return_output = check_output(cmd, shell=True)
+#print(return_output.split("\n"))
+
for line in return_output.split("\n"):
if not line == "":
r.add_commit(Commit(line))
r.resolve_parents()
+
+# extract Branches
cmd = "git branch -av | cut -b 3-"
return_output = check_output(cmd, shell=True)
+#print(return_output.split("\n"))
+
for line in return_output.split("\n"):
if not line == "":
r.add_branch(Branch(line))
-print(return_output.split("\n"))
\ No newline at end of file
+r.export_to_tikz()
\ No newline at end of file
--- /dev/null
+\begin{tikzpicture}
+\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, blue, fill=blue] (3dbbd41) at (0.0,0) {};
+\node[right,xshift=10] (label_3dbbd41) at (3dbbd41.east) {\verb!3dbbd41: [py] commit & branch läuft!};
+\node[commit, blue, fill=blue] (afd6f5a) at (0.0,-0.5) {};
+\node[right,xshift=10] (label_afd6f5a) at (afd6f5a.east) {\verb!afd6f5a: [py] Commit funktioniert!};
+\path[blue] (afd6f5a) to[out=90,in=-90] (3dbbd41);
+\node[commit, blue, fill=blue] (9ebee64) at (0.0,-1.0) {};
+\node[right,xshift=10] (label_9ebee64) at (9ebee64.east) {\verb!9ebee64: [py] init & git shell!};
+\path[blue] (9ebee64) to[out=90,in=-90] (afd6f5a);
+\node[commit, blue, fill=blue] (d78896f) at (0.0,-1.5) {};
+\node[right,xshift=10] (label_d78896f) at (d78896f.east) {\verb!d78896f: [doc] kleine änderrung!};
+\path[blue] (d78896f) to[out=90,in=-90] (e5c3cd5);
+\node[commit, blue, fill=blue] (e5c3cd5) at (0.0,-2.0) {};
+\node[right,xshift=10] (label_e5c3cd5) at (e5c3cd5.east) {\verb!e5c3cd5: added Ruby Skript!};
+\path[blue] (e5c3cd5) to[out=90,in=-90] (9ebee64);
+\node[commit, blue, fill=blue] (a6f6d74) at (0.0,-2.5) {};
+\node[right,xshift=10] (label_a6f6d74) at (a6f6d74.east) {\verb!a6f6d74: Grober Latex Test!};
+\path[blue] (a6f6d74) to[out=90,in=-90] (d78896f);
+\node[branch,right,xshift=10] (feature/python) at (label_3dbbd41.east) {\lstinline{feature/python}};
+\node[branch,right,xshift=10] (master) at (label_e5c3cd5.east) {\lstinline{master}};
+\end{tikzpicture}