File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -74,10 +74,9 @@ def sync_repository(
7474 year_ago = timezone .now () - td (days = 365 )
7575
7676 # GitHub repository commits.
77- latest_commit = (
78- Commit . objects . filter ( repository = repository ). order_by ( "-created_at" ). first ()
77+ since = (
78+ latest_commit . created_at if ( latest_commit := repository . latest_commit ) else year_ago
7979 )
80- since = latest_commit .created_at if latest_commit else year_ago
8180
8281 commits_to_save = []
8382 for gh_commit in gh_repository .get_commits (since = since ):
Original file line number Diff line number Diff line change @@ -113,6 +113,16 @@ def __str__(self):
113113 """
114114 return self .path
115115
116+ @property
117+ def latest_commit (self ):
118+ """Get the latest commit for the repository.
119+
120+ Returns
121+ Commit: The most recently created commit.
122+
123+ """
124+ return self .commits .order_by ("-created_at" ).first ()
125+
116126 @property
117127 def latest_pull_request (self ):
118128 """Get the latest pull request for the repository.
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ def mock_common_deps(mocker):
3535 mock_repository .latest_updated_milestone = None
3636 mock_repository .latest_updated_issue = None
3737 mock_repository .latest_updated_pull_request = None
38+ mock_repository .latest_commit = None
3839 mock_repository .id = 1
3940
4041 return mocks
You can’t perform that action at this time.
0 commit comments