Index: testing_support/git_test_utils.py |
diff --git a/testing_support/git_test_utils.py b/testing_support/git_test_utils.py |
index fbe7c73c302883a67a2c9ba9b13e7cac49916c8a..a08e8189f8b6438518e55b1c697de2ed37ca31bb 100644 |
--- a/testing_support/git_test_utils.py |
+++ b/testing_support/git_test_utils.py |
@@ -93,6 +93,24 @@ class OrderedSet(collections.MutableSet): |
return key |
+class UTC(datetime.tzinfo): |
+ """UTC time zone. |
+ |
+ from https://docs.python.org/2/library/datetime.html#tzinfo-objects |
+ """ |
+ def utcoffset(self, dt): |
+ return datetime.timedelta(0) |
+ |
+ def tzname(self, dt): |
+ return "UTC" |
+ |
+ def dst(self, dt): |
+ return datetime.timedelta(0) |
+ |
+ |
+UTC = UTC() |
+ |
+ |
class GitRepoSchema(object): |
"""A declarative git testing repo. |
@@ -267,7 +285,7 @@ class GitRepo(object): |
""" |
self.repo_path = tempfile.mkdtemp(dir=self.BASE_TEMP_DIR) |
self.commit_map = {} |
- self._date = datetime.datetime(1970, 1, 1) |
+ self._date = datetime.datetime(1970, 1, 1, tzinfo=UTC) |
self.to_schema_refs = ['--branches'] |
@@ -360,6 +378,11 @@ class GitRepo(object): |
except subprocess.CalledProcessError as e: |
return self.COMMAND_OUTPUT(e.returncode, e.output) |
+ def show_commit(self, commit_name, format_string): |
+ """Shows a commit (by its schema name) with a given format string.""" |
+ return self.git('show', '-q', '--pretty=format:%s' % format_string, |
+ self[commit_name]).stdout |
+ |
def git_commit(self, message): |
return self.git('commit', '-am', message, env=self.get_git_commit_env()) |