|
@@ -7,6 +7,7 @@
|
|
|
|
|
|
import binascii
|
|
|
import collections
|
|
|
+import datetime
|
|
|
import os
|
|
|
import shutil
|
|
|
import signal
|
|
@@ -21,6 +22,8 @@ sys.path.insert(0, DEPOT_TOOLS_ROOT)
|
|
|
from testing_support import coverage_utils
|
|
|
from testing_support import git_test_utils
|
|
|
|
|
|
+GitRepo = git_test_utils.GitRepo
|
|
|
+
|
|
|
|
|
|
class GitCommonTestBase(unittest.TestCase):
|
|
|
@classmethod
|
|
@@ -926,7 +929,7 @@ class GitMakeWorkdir(git_test_utils.GitRepoReadOnlyTestBase, GitCommonTestBase):
|
|
|
|
|
|
class GitTestUtilsTest(git_test_utils.GitRepoReadOnlyTestBase):
|
|
|
REPO_SCHEMA = """
|
|
|
- A B
|
|
|
+ A B C
|
|
|
"""
|
|
|
|
|
|
COMMIT_A = {
|
|
@@ -937,6 +940,19 @@ class GitTestUtilsTest(git_test_utils.GitRepoReadOnlyTestBase):
|
|
|
'file1': {'data': 'file1 changed'},
|
|
|
}
|
|
|
|
|
|
+ # Test special keys (custom commit data).
|
|
|
+ COMMIT_C = {
|
|
|
+ GitRepo.AUTHOR_NAME: 'Custom Author',
|
|
|
+ GitRepo.AUTHOR_EMAIL: 'author@example.com',
|
|
|
+ GitRepo.AUTHOR_DATE: datetime.datetime(1980, 9, 8, 7, 6, 5,
|
|
|
+ tzinfo=git_test_utils.UTC),
|
|
|
+ GitRepo.COMMITTER_NAME: 'Custom Committer',
|
|
|
+ GitRepo.COMMITTER_EMAIL: 'committer@example.com',
|
|
|
+ GitRepo.COMMITTER_DATE: datetime.datetime(1990, 4, 5, 6, 7, 8,
|
|
|
+ tzinfo=git_test_utils.UTC),
|
|
|
+ 'file1': {'data': 'file1 changed again'},
|
|
|
+ }
|
|
|
+
|
|
|
def testAutomaticCommitDates(self):
|
|
|
# The dates should start from 1970-01-01 and automatically increment. They
|
|
|
# must be in UTC (otherwise the tests are system-dependent, and if your
|
|
@@ -951,6 +967,13 @@ class GitTestUtilsTest(git_test_utils.GitRepoReadOnlyTestBase):
|
|
|
self.assertEquals('Charles Committish 1970-01-04 00:00:00 +0000',
|
|
|
self.repo.show_commit('B', format_string='%cn %ci'))
|
|
|
|
|
|
+ def testCustomCommitData(self):
|
|
|
+ self.assertEquals('Custom Author author@example.com '
|
|
|
+ '1980-09-08 07:06:05 +0000',
|
|
|
+ self.repo.show_commit('C', format_string='%an %ae %ai'))
|
|
|
+ self.assertEquals('Custom Committer committer@example.com '
|
|
|
+ '1990-04-05 06:07:08 +0000',
|
|
|
+ self.repo.show_commit('C', format_string='%cn %ce %ci'))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
sys.exit(coverage_utils.covered_main(
|