Skip to content

Commit

Permalink
Merge pull request #299 from m-aciek/git-authored-date
Browse files Browse the repository at this point in the history
Use authored date instead of committed date as git file timestamp
  • Loading branch information
Apmats authored Sep 25, 2020
2 parents bbeb188 + 48a94f7 commit 9306753
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import time
import unittest
import six
from mock import patch, MagicMock, mock_open
from mock import patch, MagicMock, Mock, mock_open
from urllib3.exceptions import SSLError

from txclib import utils, exceptions
Expand Down Expand Up @@ -383,4 +383,13 @@ def test_git_timestamp_is_parsable(self):
os.path.dirname(os.path.abspath(__file__))
)
parsed_ts = time.mktime(time.gmtime(epoch_ts))
self.assertIsNotNone(parsed_ts)
self.assertIsNotNone(parsed_ts)

def test_uses_authorized_date(self):
commit = Mock()
commit.authored_date = 1590969254
commit.committed_date = 1590970456
with patch('txclib.utils.git.Repo') as repo:
repo.return_value.iter_commits.return_value = [commit]
epoch_ts = utils.get_git_file_timestamp('any')
self.assertEqual(1590969254, epoch_ts)
2 changes: 1 addition & 1 deletion txclib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def get_git_file_timestamp(file_path):
)
if commits_touching_path:
latest_commit = commits_touching_path[0]
latest_commit_ts = latest_commit.committed_date
latest_commit_ts = latest_commit.authored_date
return latest_commit_ts
else:
return None
Expand Down

0 comments on commit 9306753

Please sign in to comment.