Split out _dates from _years in GitBackend.
authorW. Trevor King <wking@drexel.edu>
Wed, 14 Mar 2012 11:38:24 +0000 (07:38 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 14 Mar 2012 11:38:24 +0000 (07:38 -0400)
This makes it easier for external modules to use the GitBackend to do
different things with the extracted list of dates.

update_copyright/vcs/git.py

index 65411fe2e3db6de2a6f9a87ada428b4890e8dbbc..fd6b85f72e99a68e640c20240d7ea8ae9c2d6d38 100644 (file)
@@ -42,14 +42,18 @@ class GitBackend (_VCSBackend):
             ['git'] + list(args), cwd=self._root, unicode_output=True)
         return stdout.rstrip('\n')
 
-    def _years(self, filename=None):
+    def _dates(self, filename=None):
         args = ['log'] + self._year_format
         if filename is not None:
             args.extend(['--follow'] + [filename])
         output = self._git_cmd(*args)
         if self._version.startswith('1.5.'):
             output = '\n'.join([x.split()[0] for x in output.splitlines()])
-        years = set(int(line.split('-', 1)[0]) for line in output.splitlines())
+        return output.splitlines()
+
+    def _years(self, filename=None):
+        dates = self._dates(filename=filename)
+        years = set(int(line.split('-', 1)[0]) for date in dates)
         return years
 
     def _authors(self, filename=None):