From 99fea3cf24dca6ab5c4ca91513ac7521e92c469f Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Sun, 14 Oct 2018 22:58:56 +0200
Subject: [PATCH] first check, if existing notice is identical to new one

---
 do-copyright.py | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/do-copyright.py b/do-copyright.py
index dcbd9d05..2953476d 100755
--- a/do-copyright.py
+++ b/do-copyright.py
@@ -42,13 +42,23 @@ def checkNote(filename):
             endNote = iLine
         iLine += 1
 
-    #if startNote>=0 and endNote>=0 and isCopyright:
-    #print filename
-    #for iLine in range(startNote, endNote+1):
-    #   print lines[iLine]
-
-    os.rename(filename, filename+".bak")
+    # now check if copyright notice is already there and identical...
+    isSame = True
+    if startNote>=0 and endNote>=0 and isCopyright:
+        noteLines = text.split('\n')        
+        for iLine in range(len(noteLines)):
+            if noteLines[iLine] != lines[startNote+iLine]:
+                isSame = False
+                print "not same: " + noteLines[iLine] + " " + lines[startNote+iLine]
+
+    # check if notice is the same 
+    if isSame:
+        return                
     
+    # add (new) copyright notice here:
+        
+    os.rename(filename, filename+".bak")
+
     with open(filename, "w") as file:
 
         file.write(text)
-- 
GitLab