UpdateChangeLog: update copyright year in header
authorZac Medico <zmedico@gentoo.org>
Mon, 17 Oct 2011 01:11:22 +0000 (18:11 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 17 Oct 2011 01:11:22 +0000 (18:11 -0700)
This feature got dropped on commit
b655137b7b5f87c11a7e742b7ef0e028a1139677.

pym/repoman/utilities.py

index 5b9eaf74146f05faaadfd7704b8eb174b40f4ffa..e4fc1a45bf787db603f02cf64a16410cd8058d70 100644 (file)
@@ -28,6 +28,7 @@ import io
 from itertools import chain
 import logging
 import pwd
+import re
 import sys
 import time
 import textwrap
@@ -549,6 +550,7 @@ def UpdateChangeLog(pkgdir, category, package, new, removed, changed, msg, prete
        cl_path = os.path.join(pkgdir, 'ChangeLog')
        clold_lines = []
        clnew_lines = []
+       old_header_lines = []
        header_lines = []
 
        try:
@@ -583,6 +585,12 @@ def UpdateChangeLog(pkgdir, category, package, new, removed, changed, msg, prete
                                if not line_strip:
                                        break
 
+                       # update the copyright year
+                       old_header_lines = header_lines[:]
+                       if len(header_lines) >= 2:
+                               header_lines[1] = re.sub(r'^(# Copyright \d\d\d\d)-\d\d\d\d ',
+                                       r'\1-%s ' % time.strftime('%Y'), header_lines[1])
+
                # write new ChangeLog entry
                clnew_lines.extend(header_lines)
                date = time.strftime('%d %b %Y')
@@ -620,9 +628,9 @@ def UpdateChangeLog(pkgdir, category, package, new, removed, changed, msg, prete
                        for line in clold_lines:
                                f.write(line)
 
-                       # Now prepend header_lines to clold_lines, for use
+                       # Now prepend old_header_lines to clold_lines, for use
                        # in the unified_diff call below.
-                       clold_lines = header_lines + clold_lines
+                       clold_lines = old_header_lines + clold_lines
 
                        for line in clold_file:
                                f.write(line)