]> git.leopard-lacewing.eu Git - tex_tools.git/commitdiff
[py] Commit funktioniert
authorPeter Schaefer <schaeferpm@gmail.com>
Wed, 2 Jan 2019 20:07:59 +0000 (21:07 +0100)
committerPeter Schaefer <schaeferpm@gmail.com>
Wed, 2 Jan 2019 20:07:59 +0000 (21:07 +0100)
git-log-to-tikz.py

index e056b15cdc39b7b915c74852cd85aa374bad2a09..c1da957469a8a1bef5c6172eaf697c17c14881f6 100644 (file)
@@ -1,19 +1,39 @@
-from subprocess import Popen, check_output
+from subprocess import check_output
+import re
 
+hashpat = re.compile(r"[a-f0-9]{7}")
+linepat = re.compile(r'[^|\/\\]')
 
 class Commit:
+    _line = None
     _hash = None
     _children = None
-    _parents = None
-    _message = None
+    _parents = {}
+    _message= None
+    _message_pos = None
     _node_pos = None
     _node_color = None
 
-    def __init__(self):
-        self._children = hash.__new__()
-        self._parents = hash.__new__()
-        self._message = ""
-        self._node_pos = 0
+    def __init__(self,line):
+      
+        self._line = line
+        pos = 0
+        for word in line.split(" "):
+            if self._message:
+                self._message += " " + word
+            elif hashpat.match(word):
+                if not self._hash:
+                    self._hash = word
+                else:
+                    self._parents[word] = NotImplemented
+            elif word == '*' and not self._message:
+                self._node_pos = pos
+            elif linepat.match(word):
+                self._message = word
+                self._message_pos = pos
+
+            pos = pos + 1         
+
     
 
 class Branch:
@@ -35,9 +55,23 @@ class Branch:
     def to_s(self):
         print(" ".join({self._name, self._hash, self._commit}))
 
+class Repo:
+    _commits = {}
+
+    def add_commit(self, commit):
+        if commit._hash:
+            self._commits[commit._hash] = commit
+
 
 cmd = "git log --graph --oneline --parents"
 
 return_output = check_output(cmd, shell=True)
 
 print(return_output.split("\n"))
+
+r = Repo()
+
+for line in return_output.split("\n"):
+    r.add_commit(Commit(line))
+
+print()
\ No newline at end of file