Skip to content

Commit f7cff58

Browse files
dries007Byron
authored andcommitted
Added parsing for '@1400000000 +0000' date format as used by git commit hooks.
1 parent 313b3b4 commit f7cff58

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Diff for: AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ Contributors are:
3737
-Anil Khatri <anil.soccer.khatri _at_ gmail.com>
3838
-JJ Graham <thetwoj _at_ gmail.com>
3939
-Ben Thayer <ben _at_ benthayer.com>
40+
-Dries Kennes <admin _at_ dries007.net>
4041

4142
Portions derived from other open source works and are clearly marked.

Diff for: git/objects/util.py

+2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ def parse_date(string_date):
148148
try:
149149
if string_date.count(' ') == 1 and string_date.rfind(':') == -1:
150150
timestamp, offset = string_date.split()
151+
if timestamp.startswith('@'):
152+
timestamp = timestamp[1:]
151153
timestamp = int(timestamp)
152154
return timestamp, utctz_to_altz(verify_utctz(offset))
153155
else:

Diff for: git/test/test_repo.py

+6
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ def test_clone_from_keeps_env(self, rw_dir):
220220

221221
assert_equal(environment, cloned.git.environment())
222222

223+
@with_rw_directory
224+
def test_date_format(self, rw_dir):
225+
repo = Repo.init(osp.join(rw_dir, "repo"))
226+
# @-timestamp is the format used by git commit hooks
227+
repo.index.commit("Commit messages", commit_date="@1400000000 +0000")
228+
223229
@with_rw_directory
224230
def test_clone_from_pathlib(self, rw_dir):
225231
if pathlib is None: # pythons bellow 3.4 don't have pathlib

0 commit comments

Comments
 (0)