Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BB2E3D9DE for ; Wed, 10 Oct 2012 17:56:23 +0000 (UTC) Received: (qmail 74499 invoked by uid 500); 10 Oct 2012 17:56:23 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 74464 invoked by uid 500); 10 Oct 2012 17:56:23 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 74442 invoked by uid 99); 10 Oct 2012 17:56:23 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Oct 2012 17:56:23 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 471643D46F; Wed, 10 Oct 2012 17:56:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: johnsca@apache.org To: allura-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: [#4820] ticket:180 add repo_refreshed event Message-Id: <20121010175623.471643D46F@tyr.zones.apache.org> Date: Wed, 10 Oct 2012 17:56:23 +0000 (UTC) Updated Branches: refs/heads/master 5448d2496 -> f872fad17 [#4820] ticket:180 add repo_refreshed event Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/235d865d Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/235d865d Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/235d865d Branch: refs/heads/master Commit: 235d865d5ecc83fa32eaec65ac2cf5a23183a5ea Parents: 5448d24 Author: Anton Kasyanov Authored: Fri Sep 28 16:46:16 2012 +0300 Committer: Cory Johns Committed: Wed Oct 10 17:54:36 2012 +0000 ---------------------------------------------------------------------- Allura/allura/model/repo_refresh.py | 7 ++++++- Allura/allura/tests/model/test_repo.py | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/235d865d/Allura/allura/model/repo_refresh.py ---------------------------------------------------------------------- diff --git a/Allura/allura/model/repo_refresh.py b/Allura/allura/model/repo_refresh.py index 4b8c1af..87e436e 100644 --- a/Allura/allura/model/repo_refresh.py +++ b/Allura/allura/model/repo_refresh.py @@ -7,6 +7,8 @@ import bson import tg +from pylons import g + from ming.base import Object from ming.orm import mapper, session @@ -97,7 +99,10 @@ def refresh_repo(repo, all_commits=False, notify=True): log.info('Compute diffs %d: %s', (i+1), ci._id) log.info('Refresh complete for %s', repo.full_fs_path) - + g.post_event( + 'repo_refreshed', + commit_number=len(commit_ids), + new=bool(new_commit_ids)) # Send notifications if notify: send_notifications(repo, commit_ids) http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/235d865d/Allura/allura/tests/model/test_repo.py ---------------------------------------------------------------------- diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py index 3801c9f..3cf07d1 100644 --- a/Allura/allura/tests/model/test_repo.py +++ b/Allura/allura/tests/model/test_repo.py @@ -191,7 +191,10 @@ class TestRepo(_TestWithRepo): self.repo._impl.refresh_heads = mock.Mock(side_effect=set_heads) self.repo.shorthand_for_commit = lambda oid: '[' + str(oid) + ']' self.repo.url_for_commit = lambda oid: '/ci/' + str(oid) + '/' - self.repo.refresh() + with mock.patch('allura.model.repo_refresh.g.post_event') as post_event: + self.repo.refresh() + post_event.assert_called_with( + 'repo_refreshed', commit_number=100, new=True) ThreadLocalORMSession.flush_all() notifications = M.Notification.query.find().all() for n in notifications: @@ -519,4 +522,4 @@ class RepoImplTestBase(object): run = runs[0] self.assertEqual(run.commit_ids, commit_ids) self.assertEqual(len(run.commit_ids), len(run.commit_times)) - self.assertEqual(run.parent_commit_ids, []) \ No newline at end of file + self.assertEqual(run.parent_commit_ids, [])