]> git.leopard-lacewing.eu Git - tex_tools.git/commitdiff
-o functioniert (traumhaft)
authorPeter Schaefer <schaeferpm@gmail.com>
Sun, 17 Feb 2019 12:10:29 +0000 (13:10 +0100)
committerPeter Schaefer <schaeferpm@gmail.com>
Sun, 17 Feb 2019 12:10:29 +0000 (13:10 +0100)
git1.tex
gitLog2tikz.py
text-output.pdf

index 41b723a37e501d0890692d27ff678741f0fa7507..e5fb4030ed26076c7ebc9b53bcba9d3751a07551 100644 (file)
--- a/git1.tex
+++ b/git1.tex
@@ -5,7 +5,7 @@
 \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[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) {};
@@ -13,7 +13,7 @@
 \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[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] (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, blue, fill=blue] (16d4f59) at (0.5,6.5) {};
-\node[right,xshift=10] (label16d4f59) at (16d4f59.east) {\verb!16d4f59: [doc] test!};
-\node[commit, black, fill=black] (53e02cf) at (0.0,7.0) {};
+\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.5) {};
+\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,8.0) {};
+\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.5) {};
+\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, brown, fill=brown] (feccffc) at (1.0,10.0) {};
-\node[right,xshift=10] (labelfeccffc) at (feccffc.east) {\verb!feccffc: Merge branch 'develop'!};
-\node[commit, brown, fill=brown] (1b6432e) at (1.0,10.5) {};
-\node[right,xshift=10] (label1b6432e) at (1b6432e.east) {\verb!1b6432e: merge successful!};
-\node[commit, blue, fill=blue] (827f503) at (0.5,11.0) {};
+\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,11.5) {};
+\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,12.0) {};
+\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,12.5) {};
+\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,13.0) {};
+\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, brown, fill=brown] (65dae54) at (1.0,13.5) {};
-\node[right,xshift=10] (label65dae54) at (65dae54.east) {\verb!65dae54: Merge branch 'develop'!};
-\node[commit, black, fill=black] (d477a13) at (0.0,14.0) {};
-\node[right,xshift=10] (labeld477a13) at (d477a13.east) {\verb!d477a13: [doc] neuer Branch !};
-\node[commit, blue, fill=blue] (71f4986) at (0.5,14.5) {};
+\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,15.0) {};
+\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,15.5) {};
+\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,16.0) {};
+\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,16.5) {};
+\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!};
-\node[commit, black, fill=black] (a53824c) at (0.0,17.0) {};
+\node[commit, black, fill=black] (a53824c) at (0.0,15.0) {};
 \node[right,xshift=10] (labela53824c) at (a53824c.east) {\verb!a53824c: fixed some issues!};
-\node[commit, black, fill=black] (0f95945) at (0.0,17.5) {};
+\node[commit, black, fill=black] (0f95945) at (0.0,15.5) {};
 \node[right,xshift=10] (label0f95945) at (0f95945.east) {\verb!0f95945: . fix for messages!};
+\node[commit, black, fill=black] (a0c0aef) at (0.0,16.0) {};
+\node[right,xshift=10] (labela0c0aef) at (a0c0aef.east) {\verb!a0c0aef: branches get loaded correctly!};
+\node[commit, black, fill=black] (625259d) at (0.0,16.5) {};
+\node[right,xshift=10] (label625259d) at (625259d.east) {\verb!625259d: save Merged Info!};
+\path[black] (a0c0aef) to[out=90,in=-90] (625259d);
+\path[black] (0f95945) to[out=90,in=-90] (a0c0aef);
 \path[black] (a53824c) to[out=90,in=-90] (0f95945);
 \path[black] (769f9d1) to[out=90,in=-90] (a53824c);
 \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[black] (d477a13) to[out=90,in=-90] (7c94d50);
 \path[blue] (ddec20f) to[out=90,in=-90] (71f4986);
-\path[blue] (ddec20f) to[out=90,in=-90] (65dae54);
 \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[brown] (1b6432e) to[out=90,in=-90] (65dae54);
-\path[brown] (feccffc) to[out=90,in=-90] (1b6432e);
 \path[blue] (6b30984) to[out=90,in=-90] (827f503);
-\path[blue] (6b30984) to[out=90,in=-90] (feccffc);
 \path[blue] (d2bf877) to[out=90,in=-90] (6b30984);
-\path[black] (7ef61eb) to[out=90,in=-90] (d477a13);
+\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[blue] (16d4f59) to[out=90,in=-90] (feccffc);
 \path[black] (6e41ab0) to[out=90,in=-90] (53e02cf);
-\path[black] (6e41ab0) to[out=90,in=-90] (16d4f59);
 \path[black] (2256509) to[out=90,in=-90] (6e41ab0);
 \path[black] (8a5d531) to[out=90,in=-90] (2256509);
 \path[black] (7ac7de4) to[out=90,in=-90] (8a5d531);
 \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] (feature/python2) at (label0f95945.east) {\lstinline{feature/python2}};
-\node[branch,right,xshift=10] (master) at (label65dae54.east) {\lstinline{master}};
-\node[branch,right,xshift=10] (origin/HEAD) at (label65dae54.east) {\lstinline{origin/HEAD}};
+\node[branch,right,xshift=10] (develop) at (labela0c0aef.east) {\lstinline{develop}};
+\node[branch,right,xshift=10] (feature/python2) at (label625259d.east) {\lstinline{feature/python2}};
 \node[branch,right,xshift=10] (origin/develop) at (label71f4986.east) {\lstinline{origin/develop}};
 \node[branch,right,xshift=10] (origin/feature/python) at (label6b30984.east) {\lstinline{origin/feature/python}};
 \node[branch,right,xshift=10] (origin/feature/python2) at (label769f9d1.east) {\lstinline{origin/feature/python2}};
-\node[branch,right,xshift=10] (origin/master) at (label65dae54.east) {\lstinline{origin/master}};
 \end{tikzpicture}
index bbced7606d85f6bd564e90e9d468282ed2fc5fb6..21ab9c5edc84a874074b1abd691f0f06a4e99b4d 100644 (file)
@@ -8,14 +8,10 @@ from re import compile, match
 from argparse import ArgumentParser
 import sys
 
-# Importer fast fertig
-# Aber die light Variante
+out_stream = sys.stdout
 
-linepat = compile(r'[^|\/\\]')
-
-#def print(line):
-#    line = line.encode('utf-16LE')
-#    sys.stdout.buffer.write(line)
+def out(line):
+    print(line,file=out_stream)
 
 def color(numb):
     numb = int(numb)
@@ -80,7 +76,7 @@ class Branch:
             return self._name
 
     def export_branch2tikz(self):
-        print("\\node[branch,right,xshift=10] (" + self.name() + ") at (label" + self.hash() + ".east) {\\lstinline{" + self.name() +"}};")
+        out("\\node[branch,right,xshift=10] (" + self.name() + ") at (label" + self.hash() + ".east) {\\lstinline{" + self.name() +"}};")
         
     def __eq__(self,other):
         return self.name() == other
@@ -109,7 +105,7 @@ class Repo:
                 for c in line:
                     if c == '*':
                         node_pos = pos
-                    elif linepat.match(c) and c != ' ':
+                    elif c not in " |\\/":
                         message_pos = pos
                         break
                     pos = pos + 1
@@ -147,10 +143,10 @@ class Repo:
                     
 
     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]")
+        out("\\begin{tikzpicture}")
+        out("\\tikzstyle{commit}=[draw,circle,fill=white,inner sep=0pt,minimum size=5pt]")
+        out("\\tikzstyle{every path}=[draw]")
+        out("\\tikzstyle{branch}=[draw,rectangle,rounded corners=3,fill=white,inner sep=2pt,minimum size=5pt]")
 
         #Draw Commit Info
         ypos = 0
@@ -168,7 +164,7 @@ class Repo:
         for branch in self._branches:
             branch.export_branch2tikz()
 
-        print("\\end{tikzpicture}")
+        out("\\end{tikzpicture}")
 
     class Commit:
         def __init__(self,hashes,node_pos,message_pos):
@@ -212,44 +208,51 @@ class Repo:
             child._children[self.hash()] = self
 
         def export_commit2tikz(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() + ": " + VerbClean(self._message) + "!};")
+            out("\\node[commit, " + color(self._node_pos) + ", fill=" +  color(self._node_pos) + "] (" + self.hash() + ") at (" + str(.5 * self._node_pos) + "," + str(ypos) + ") {};")
+            out("\\node[right,xshift=10] (label" + self.hash() + ") at (" + self.hash() + ".east) {\\verb!" + self.hash() + ": " + VerbClean(self._message) + "!};")
 
         def export_path2tikz(self):
             for child in self._children.values():
-                print("\\path[" +  color(self._node_pos) +"] (" + self.hash() + ") to[out=90,in=-90] (" + child.hash() + ");") 
+                out("\\path[" +  color(self._node_pos) +"] (" + self.hash() + ") to[out=90,in=-90] (" + child.hash() + ");") 
        
         def __eq__(self,other):
             return self.hash() == other.hash()
 
-#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")
+args = ArgumentParser()
+#args.add_argument("-o","--ofile", help="outputfile", dest="ofile", metavar="outputfile")
+
+#args.add_argument("-f","--file",help="show history of one file", dest="hfile")
+#args.add_argument("-a", help="show author", dest="author", action="store_false")
+
+args.add_argument("--log_opts", help="additional options for git log", dest="log_opts", metavar='<LOG_OPTS>')
+args.add_argument("--branch_opts", help="additional options for git branch", dest="branch_opts", metavar='<BRANCH_OPTS>')
 
-#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.add_argument("-o","--ofile", help="write output to <FILE>", dest="file", metavar="<FILE>")
 
-#args = parser.parse_args()
+options = args.parse_args()
 
 
 #new Repo
 r =  Repo()
 
 # extract Commits
-cmd = "git log --graph --branches --parents"
+cmd = "git log --graph --parents"
+if options.log_opts:
+#    log_opts = options.log_opts.strip()
+#    if log_opts[0] == log_opts[-1] and log_opts[0] in "\"'":
+#        log_opts = log_opts[1:-1]
+    cmd = cmd + ' ' + options.log_opts
 
-return_output = check_output(cmd, shell=True, encoding='utf-8')
-#print(return_output.split("\n"))
-
-#Fill Repo with commits
-r.add_commitlog(return_output)
+r.add_commitlog(check_output(cmd, shell=True, encoding='utf-8'))
 
 # extract Branches
 cmd = "git branch -va" # | cut -b 3-"
+if options.branch_opts:
+    cmd = cmd + ' ' + options.branch_opts
 
-return_output = check_output(cmd, shell=True, encoding='utf-8')
-#print(return_output.split("\n"))
-
-r.add_branchlog(return_output)
+r.add_branchlog(check_output(cmd, shell=True, encoding='utf-8'))
 
-r.export_to_tikz()
\ No newline at end of file
+if options.file:
+    with open(options.file,"w", encoding="utf-8") as out_stream:
+        #Export
+        r.export_to_tikz()
\ No newline at end of file
index b218bdd505258c9c3ba5bd52c5a8a519c35dddaf..715d359de6ff2a1af4803af8d4c6362e7dacceb9 100644 (file)
Binary files a/text-output.pdf and b/text-output.pdf differ