diff options
author | Dries <admin@dries007.net> | 2019-12-08 15:20:29 +0100 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2019-12-29 11:23:41 +0800 |
commit | f7cff58fd53bdb50fef857fdae65ee1230fd0061 (patch) | |
tree | 2fb9d6af85b9e1b58daa6a47b66cf4233fe5a797 | |
parent | 313b3b4425012528222e086b49359dacad26d678 (diff) | |
download | gitpython-f7cff58fd53bdb50fef857fdae65ee1230fd0061.tar.gz |
Added parsing for '@1400000000 +0000' date format as used by git commit hooks.
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | git/objects/util.py | 2 | ||||
-rw-r--r-- | git/test/test_repo.py | 6 |
3 files changed, 9 insertions, 0 deletions
@@ -37,5 +37,6 @@ Contributors are: -Anil Khatri <anil.soccer.khatri _at_ gmail.com> -JJ Graham <thetwoj _at_ gmail.com> -Ben Thayer <ben _at_ benthayer.com> +-Dries Kennes <admin _at_ dries007.net> Portions derived from other open source works and are clearly marked. diff --git a/git/objects/util.py b/git/objects/util.py index 5dbd9822..235b520e 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -148,6 +148,8 @@ def parse_date(string_date): try: if string_date.count(' ') == 1 and string_date.rfind(':') == -1: timestamp, offset = string_date.split() + if timestamp.startswith('@'): + timestamp = timestamp[1:] timestamp = int(timestamp) return timestamp, utctz_to_altz(verify_utctz(offset)) else: diff --git a/git/test/test_repo.py b/git/test/test_repo.py index c59203ed..ef28c74e 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -221,6 +221,12 @@ class TestRepo(TestBase): assert_equal(environment, cloned.git.environment()) @with_rw_directory + def test_date_format(self, rw_dir): + repo = Repo.init(osp.join(rw_dir, "repo")) + # @-timestamp is the format used by git commit hooks + repo.index.commit("Commit messages", commit_date="@1400000000 +0000") + + @with_rw_directory def test_clone_from_pathlib(self, rw_dir): if pathlib is None: # pythons bellow 3.4 don't have pathlib raise SkipTest("pathlib was introduced in 3.4") |