launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #18666
[Merge] lp:~cjwatson/launchpad/git-ref-scan-modifies into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/git-ref-scan-modifies into lp:launchpad.
Commit message:
Update GitRepository.date_last_modified when recording Git ref updates.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/git-ref-scan-modifies/+merge/260742
We should update GitRepository.date_last_modified when refs within the repository change; partly because it makes sense, and partly because it will make efficient backups easier in future.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/git-ref-scan-modifies into lp:launchpad.
=== modified file 'lib/lp/code/model/gitrepository.py'
--- lib/lp/code/model/gitrepository.py 2015-05-26 12:18:12 +0000
+++ lib/lp/code/model/gitrepository.py 2015-06-01 16:10:53 +0000
@@ -497,6 +497,7 @@
else:
created = []
+ self.date_last_modified = UTC_NOW
if get_objects:
return bulk.load(GitRef, updated + created)
@@ -505,6 +506,7 @@
Store.of(self).find(
GitRef,
GitRef.repository == self, GitRef.path.is_in(paths)).remove()
+ self.date_last_modified = UTC_NOW
def planRefChanges(self, hosting_client, hosting_path, logger=None):
"""See `IGitRepository`."""
=== modified file 'lib/lp/code/model/tests/test_gitrepository.py'
--- lib/lp/code/model/tests/test_gitrepository.py 2015-05-23 16:29:29 +0000
+++ lib/lp/code/model/tests/test_gitrepository.py 2015-06-01 16:10:53 +0000
@@ -644,6 +644,28 @@
self.assertSqlAttributeEqualsDate(
repository, "date_last_modified", UTC_NOW)
+ def test_create_ref_sets_date_last_modified(self):
+ repository = self.factory.makeGitRepository(
+ date_created=datetime(2015, 06, 01, tzinfo=pytz.UTC))
+ [ref] = self.factory.makeGitRefs(repository=repository)
+ new_refs_info = {
+ u"refs/heads/new": {
+ u"sha1": ref.commit_sha1,
+ u"type": ref.object_type,
+ },
+ }
+ repository.createOrUpdateRefs(new_refs_info)
+ self.assertSqlAttributeEqualsDate(
+ repository, "date_last_modified", UTC_NOW)
+
+ def test_remove_ref_sets_date_last_modified(self):
+ repository = self.factory.makeGitRepository(
+ date_created=datetime(2015, 06, 01, tzinfo=pytz.UTC))
+ [ref] = self.factory.makeGitRefs(repository=repository)
+ repository.removeRefs(set([ref.path]))
+ self.assertSqlAttributeEqualsDate(
+ repository, "date_last_modified", UTC_NOW)
+
def test_sends_notifications(self):
# Attribute modifications send mail to subscribers.
self.assertEqual(0, len(stub.test_emails))
Follow ups