]> git.leopard-lacewing.eu Git - tex_tools.git/commitdiff
[py] Export copy finished
authorPeter Schaefer <schaeferpm@gmail.com>
Wed, 2 Jan 2019 21:49:13 +0000 (22:49 +0100)
committerPeter Schaefer <schaeferpm@gmail.com>
Wed, 2 Jan 2019 21:50:07 +0000 (22:50 +0100)
git-log-to-tikz.py [changed mode: 0644->0755]
git1.tex [new file with mode: 0644]
text-output.pdf
text-output.tex

old mode 100644 (file)
new mode 100755 (executable)
index c748b14..b8a5da2
@@ -4,6 +4,8 @@ import re
 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
@@ -32,16 +34,17 @@ class Commit:
                 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=""
@@ -79,25 +82,47 @@ class Repo:
             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
diff --git a/git1.tex b/git1.tex
new file mode 100644 (file)
index 0000000..37d960c
--- /dev/null
+++ b/git1.tex
@@ -0,0 +1,24 @@
+\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}
index 6feec01d1b0197b4a955adf966b0af43d2d0036c..f3cf990d5430b20722170163fe6cbb5e4adbb9f0 100644 (file)
Binary files a/text-output.pdf and b/text-output.pdf differ
index 88c01cc5245f4c2779eca33567bce21110162e27..c6457d3185808c2d394dc29f9a272cdea4abc7dd 100644 (file)
@@ -1,5 +1,11 @@
 \documentclass[]{scrartcl}
 
+\usepackage{xcolor}
+\usepackage{tikz}
+\usepackage{listings}
+\usepackage[german]{babel}
+
+
 %opening
 \title{Git Test}
 \author{Peter Schaefer}
@@ -12,6 +18,8 @@
                In diesem Versuch soll in Latex die Git History eingeblendet werden. Nach möglichkeit sogar mit verschiedenen Designs.
        \end{abstract}
        
-       \section{Erster Versuch}
+       \section{Erster Versuch }
+       
+       \include{git1}
        
 \end{document}