Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Unified Diff: testing_support/git_test_utils.py

Issue 1640973002: git_test_utils: Automatic commit dates are now in UTC. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/git_common_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« no previous file with comments | « no previous file | tests/git_common_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698