Add `filename=None` default option to Git's `original_year()`.
authorW. Trevor King <wking@drexel.edu>
Thu, 9 Feb 2012 19:10:16 +0000 (14:10 -0500)
committerW. Trevor King <wking@drexel.edu>
Thu, 9 Feb 2012 19:12:28 +0000 (14:12 -0500)
This had gotten lost in the previous merge.

update_copyright.py

index 4ca5e647c881c99038dacb507c16cb09626c74f3..647e09de33a43179bf57ee5fbe151a36faa3119e 100755 (executable)
@@ -163,14 +163,17 @@ if PROJECT_INFO['vcs'] == 'Git':
         year_format = ['--pretty=format:%ad',  # Author date
                        '--date=short']         # YYYY-MM-DD
 
-    def original_year(filename, year_hacks=YEAR_HACKS):
-        output = git_cmd(*(['log', '--follow']
-                           + year_format
-                           + [filename]))
+    def original_year(filename=None, year_hacks=YEAR_HACKS):
+        args = ['log'] + year_format
+        if filename is not None:
+            args.extend(['--follow'] + [filename])
+        output = git_cmd(*args)
         if version.startswith('1.5.'):
             output = '\n'.join([x.split()[0] for x in output.splitlines()])
         years = [int(line.split('-', 1)[0]) for line in output.splitlines()]
-        if splitpath(filename) in year_hacks:
+        if filename is None:
+            years.extend(year_hacks.values())
+        elif splitpath(filename) in year_hacks:
             years.append(year_hacks[splitpath(filename)])
         years.sort()
         return years[0]
@@ -729,7 +732,7 @@ If no files are given, a list of files to update is generated
 automatically.
 """ % PROJECT_INFO
     p = optparse.OptionParser(usage)
-    p.add_option('--pyfile', dest='pyfile', default='hooke/license.py',
+    p.add_option('--pyfile', dest='pyfile', default='update_copyright/license.py',
                  metavar='PATH',
                  help='Write project license info to a Python module at PATH')
     p.add_option('--test', dest='test', default=False,