incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [1/2] git commit: [#4820] ticket:180 add repo_refreshed event
Date Wed, 10 Oct 2012 17:56:23 GMT
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 <mind1master@gmail.com>
Authored: Fri Sep 28 16:46:16 2012 +0300
Committer: Cory Johns <johnsca@geek.net>
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, [])


Mime
View raw message