You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/02/03 23:53:27 UTC

[01/15] git commit: [#7099] Bump version of GCWikiImporter

Updated Branches:
  refs/heads/cj/7085 f8a9afd72 -> 4f9038c5e (forced update)


[#7099] Bump version of GCWikiImporter

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/a2d26270
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a2d26270
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a2d26270

Branch: refs/heads/cj/7085
Commit: a2d26270295036557aa708ef1002de2c861b7419
Parents: 3745c29
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Jan 24 21:35:25 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Fri Jan 24 21:35:25 2014 +0000

----------------------------------------------------------------------
 requirements-sf.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a2d26270/requirements-sf.txt
----------------------------------------------------------------------
diff --git a/requirements-sf.txt b/requirements-sf.txt
index e259937..8c6c040 100644
--- a/requirements-sf.txt
+++ b/requirements-sf.txt
@@ -6,7 +6,7 @@ kombu==1.0.4
 coverage==3.5a1-20110413
 ForgeHg==0.1.21
 ForgePastebin==0.3.0
-GoogleCodeWikiImporter==0.4.8
+GoogleCodeWikiImporter==0.4.9
 mechanize==0.2.4
 mercurial==1.4.3
 MySQL-python==1.2.3c1


[05/15] git commit: [#7110] importer.target_app not always a list

Posted by jo...@apache.org.
[#7110] importer.target_app not always a list

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/036905c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/036905c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/036905c2

Branch: refs/heads/cj/7085
Commit: 036905c236518ae7aa62abe8434c06ee9900a4b6
Parents: b15ef35
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Jan 28 16:49:26 2014 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Jan 28 16:49:26 2014 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/wiki.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/036905c2/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 9c00048..0bd95da 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -21,6 +21,8 @@ from datetime import datetime
 from tempfile import mkdtemp
 from shutil import rmtree
 
+from paste.deploy.converters import aslist
+
 from BeautifulSoup import BeautifulSoup
 import git
 from pylons import app_globals as g
@@ -81,7 +83,7 @@ class GitHubWikiImportController(BaseController, GitHubOAuthMixin):
 
     @property
     def target_app(self):
-        return self.importer.target_app[0]
+        return aslist(self.importer.target_app)[0]
 
     @with_trailing_slash
     @expose('jinja:forgeimporters.github:templates/wiki/index.html')


[09/15] git commit: [#6893] ticket:507 added current assigned user to input list

Posted by jo...@apache.org.
[#6893] ticket:507 added current assigned user to input list


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/208280fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/208280fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/208280fe

Branch: refs/heads/cj/7085
Commit: 208280fe90e28d57667076c27d62499a1ca7e740
Parents: 8ba6c0a
Author: Sergey Gromovoy <sg...@gmail.com>
Authored: Sat Jan 25 18:56:27 2014 +0200
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Jan 29 22:11:17 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/widgets/resources/js/combobox.js | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/208280fe/Allura/allura/lib/widgets/resources/js/combobox.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/combobox.js b/Allura/allura/lib/widgets/resources/js/combobox.js
index 6203e3b..9a20601 100644
--- a/Allura/allura/lib/widgets/resources/js/combobox.js
+++ b/Allura/allura/lib/widgets/resources/js/combobox.js
@@ -39,15 +39,21 @@
       function populateSelect(data) {
         select.children('option').remove();
         $('<option></option>').val('').appendTo(select);
+        var cur_user_in_data = false;
         for (var i = 0; i < data.options.length; i++) {
           var label = data.options[i].label,
               value = data.options[i].value;
           var option = $('<option>' + label + '</option>').val(value);
           if (selected.val() === value) {
             option.attr('selected', 'selected');  // select initial value, if any
+            cur_user_in_data = true;
           }
           option.appendTo(select);
         }
+        if (!cur_user_in_data) {
+          selected.attr('selected', 'selected');
+          selected.appendTo(select);
+        }
         loaded = true;
         if (wasOpen) {
           input.autocomplete('search', input.val());  // trigger search to re-render options


[07/15] git commit: [#7106] cache all jinja templates by default, not just 50 (prior default). configurable.

Posted by jo...@apache.org.
[#7106] cache all jinja templates by default, not just 50 (prior default).  configurable.


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/8ba6c0a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/8ba6c0a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/8ba6c0a1

Branch: refs/heads/cj/7085
Commit: 8ba6c0a17fa35e43c9bee7148aeed1c1cb8c218f
Parents: 782f0c0
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Jan 28 03:55:56 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Jan 29 22:06:08 2014 +0000

----------------------------------------------------------------------
 Allura/allura/config/app_cfg.py | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8ba6c0a1/Allura/allura/config/app_cfg.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/app_cfg.py b/Allura/allura/config/app_cfg.py
index 6a60689..1661356 100644
--- a/Allura/allura/config/app_cfg.py
+++ b/Allura/allura/config/app_cfg.py
@@ -97,6 +97,7 @@ class ForgeConfig(AppConfig):
             auto_reload=config.auto_reload_templates,
             autoescape=True,
             bytecode_cache=bcc,
+            cache_size=config.get('jinja_cache_size', -1),
             extensions=['jinja2.ext.do', 'jinja2.ext.i18n'])
         jinja2_env.install_gettext_translations(pylons.i18n)
         jinja2_env.filters['filesizeformat'] = helpers.do_filesizeformat


[02/15] git commit: [#7079] revert debug logging

Posted by jo...@apache.org.
[#7079] revert debug logging


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/49d4ea8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/49d4ea8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/49d4ea8b

Branch: refs/heads/cj/7085
Commit: 49d4ea8b2e97dea1490a609055614fd15ee6ac95
Parents: a2d2627
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Jan 24 22:29:21 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Jan 24 22:29:21 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/session.py | 42 +------------------------------------
 1 file changed, 1 insertion(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/49d4ea8b/Allura/allura/model/session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index 77f8645..68c8099 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -70,24 +70,6 @@ class ArtifactSessionExtension(SessionExtension):
             except Exception:
                 log.exception(
                     "Failed to update artifact references. Is this a borked project migration?")
-            try:
-                l = logging.getLogger('allura.debug7047')
-                from tg import request
-                task = request.environ.get('task')
-            except:
-                pass
-            else:
-                try:
-                    if task and task.task_name == 'forgetracker.tasks.bulk_edit':
-                        l.debug('this extension: %s', type(self))
-                        l.debug('active session extensions are: %s',
-                                artifact_orm_session._kwargs.get('extensions'))
-                        l.debug('threadlocal session is for: %s',
-                                [s.impl.db for s in artifact_orm_session._session_registry.values()])
-                        l.debug('current session is: %s', self.session.impl.db)
-                except Exception:
-                    log.info('error running extra debug pt1', exc_info=True)
-
             self.update_index(self.objects_deleted, arefs)
             for obj in self.objects_added:
                 g.zarkov_event('create', extra=obj.index_id())
@@ -104,30 +86,8 @@ class ArtifactSessionExtension(SessionExtension):
         if objects_deleted:
             index_tasks.del_artifacts.post(
                 [obj.index_id() for obj in objects_deleted])
-        add_task = None
         if arefs:
-            add_task = index_tasks.add_artifacts.post(
-                [aref._id for aref in arefs])
-        try:
-            l = logging.getLogger('allura.debug7047')
-            from tg import request
-            task = request.environ.get('task')
-        except:
-            pass
-        else:
-            try:
-                if task and task.task_name == 'forgetracker.tasks.bulk_edit':
-                    #l.debug('session: %s %s', self.session.impl.db, self.session)
-                    l.debug('arefs: %s', arefs)
-                    l.debug('objects_added: %s',
-                            [o._id for o in self.objects_added])
-                    l.debug('objects_modified: %s',
-                            [o._id for o in self.objects_modified])
-                    l.debug('objects_deleted: %s',
-                            [o._id for o in self.objects_deleted])
-                    l.debug('add_artifacts task: %s', add_task)
-            except Exception:
-                log.info('error running extra debug pt2', exc_info=True)
+            index_tasks.add_artifacts.post([aref._id for aref in arefs])
 
 
 class BatchIndexer(ArtifactSessionExtension):


[10/15] git commit: [#7119] Added switch for disabling template overrides

Posted by jo...@apache.org.
[#7119] Added switch for disabling template overrides

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/5bc685dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5bc685dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5bc685dd

Branch: refs/heads/cj/7085
Commit: 5bc685ddfa709dd6f350d66c5a71c24459da9e0a
Parents: 50fb9ef
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Jan 30 15:26:36 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Jan 30 15:26:36 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/package_path_loader.py        | 20 ++++++++++++--------
 .../tests/unit/test_package_path_loader.py      | 20 ++++++++++++++++++++
 Allura/test.ini                                 |  1 +
 3 files changed, 33 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5bc685dd/Allura/allura/lib/package_path_loader.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/package_path_loader.py b/Allura/allura/lib/package_path_loader.py
index fa5f71b..be28fed 100644
--- a/Allura/allura/lib/package_path_loader.py
+++ b/Allura/allura/lib/package_path_loader.py
@@ -126,6 +126,8 @@ import pkg_resources
 import os
 
 import jinja2
+from tg import config
+from paste.deploy.converters import asbool
 from ming.utils import LazyProperty
 
 from allura.lib.helpers import topological_sort, iter_entry_points
@@ -263,14 +265,16 @@ class PackagePathLoader(jinja2.BaseLoader):
         - module:path/to/template.html
         '''
         # look in all of the customized search locations...
-        try:
-            parts = [self.override_root] + template.split(':')
-            if len(parts) > 2:
-                parts[1:2] = parts[1].split('.')
-            return self.fs_loader.get_source(environment, os.path.join(*parts))
-        except jinja2.TemplateNotFound:
-            # fall-back to attempt non-override loading
-            pass
+        if not asbool(config.get('disable_template_overrides', False)):
+            try:
+                parts = [self.override_root] + template.split(':')
+                if len(parts) > 2:
+                    parts[1:2] = parts[1].split('.')
+                return self.fs_loader.get_source(environment,
+                                                 os.path.join(*parts))
+            except jinja2.TemplateNotFound:
+                # fall-back to attempt non-override loading
+                pass
 
         if ':' in template:
             package, path = template.split(':', 2)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5bc685dd/Allura/allura/tests/unit/test_package_path_loader.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_package_path_loader.py b/Allura/allura/tests/unit/test_package_path_loader.py
index c0c1519..c3109c3 100644
--- a/Allura/allura/tests/unit/test_package_path_loader.py
+++ b/Allura/allura/tests/unit/test_package_path_loader.py
@@ -20,6 +20,7 @@ from unittest import TestCase
 import jinja2
 from nose.tools import assert_equal, assert_raises
 import mock
+from tg import config
 
 from allura.lib.package_path_loader import PackagePathLoader
 
@@ -166,6 +167,7 @@ class TestPackagePathLoader(TestCase):
         assert_equal(output1, 'fs_loader')
         assert output1 is output2
 
+    @mock.patch.dict(config, {'disable_template_overrides': False})
     @mock.patch('jinja2.FileSystemLoader')
     def test_get_source(self, fs_loader):
         ppl = PackagePathLoader()
@@ -206,3 +208,21 @@ class TestPackagePathLoader(TestCase):
         assert_equal(fs_loader().get_source.call_count, 2)
         fs_loader().get_source.assert_called_with(
             'env', 'templates/audit.html')
+
+    @mock.patch('jinja2.FileSystemLoader')
+    def test_override_disable(self, fs_loader):
+        ppl = PackagePathLoader()
+        ppl.init_paths = mock.Mock()
+        fs_loader().get_source.side_effect = jinja2.TemplateNotFound('test')
+
+        assert_raises(
+            jinja2.TemplateError,
+            ppl.get_source, 'env', 'allura.ext.admin:templates/audit.html')
+        assert_equal(fs_loader().get_source.call_count, 1)
+        fs_loader().get_source.reset_mock()
+
+        with mock.patch.dict(config, {'disable_template_overrides': False}):
+            assert_raises(
+                jinja2.TemplateError,
+                ppl.get_source, 'env', 'allura.ext.admin:templates/audit.html')
+            assert_equal(fs_loader().get_source.call_count, 2)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5bc685dd/Allura/test.ini
----------------------------------------------------------------------
diff --git a/Allura/test.ini b/Allura/test.ini
index 9a11bb4..b1880b8 100644
--- a/Allura/test.ini
+++ b/Allura/test.ini
@@ -36,6 +36,7 @@ port = 5000
 [app:main]
 use = config:development.ini#tool_test
 db_prefix = test_
+disable_template_overrides = True
 
 site_name = Allura
 base_url = http://localhost


[03/15] git commit: [#7103] Fixed stale project data issue from long-running imports and bulk edits

Posted by jo...@apache.org.
[#7103] Fixed stale project data issue from long-running imports and bulk edits

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/43c4bcee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/43c4bcee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/43c4bcee

Branch: refs/heads/cj/7085
Commit: 43c4bcee7b15cff07df2fa26e2d3711584377148
Parents: 49d4ea8
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Mon Jan 27 21:07:09 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Mon Jan 27 21:07:09 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/artifact.py            |  7 +++++--
 Allura/allura/tests/model/test_artifact.py | 26 ++++++++++++++++++++++++-
 ForgeImporters/forgeimporters/base.py      | 23 +++++++++++++++++-----
 ForgeTracker/forgetracker/tasks.py         | 13 ++++++++++++-
 4 files changed, 60 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/43c4bcee/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 56c7643..fed8e02 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -65,11 +65,14 @@ class Artifact(MappedClass):
         ]
 
         def before_save(data):
-            if not getattr(artifact_orm_session._get(), 'skip_mod_date', False):
+            _session = artifact_orm_session._get()
+            skip_mod_date = getattr(_session, 'skip_mod_date', False)
+            skip_last_updated = getattr(_session, 'skip_last_updated', False)
+            if not skip_mod_date:
                 data['mod_date'] = datetime.utcnow()
             else:
                 log.debug('Not updating mod_date')
-            if c.project:
+            if c.project and not skip_last_updated:
                 c.project.last_updated = datetime.utcnow()
     type_s = 'Generic Artifact'
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/43c4bcee/Allura/allura/tests/model/test_artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_artifact.py b/Allura/allura/tests/model/test_artifact.py
index e9ac6ec..d00d935 100644
--- a/Allura/allura/tests/model/test_artifact.py
+++ b/Allura/allura/tests/model/test_artifact.py
@@ -24,7 +24,7 @@ import re
 from datetime import datetime
 
 from pylons import tmpl_context as c
-from nose.tools import assert_raises
+from nose.tools import assert_raises, assert_equal
 from nose import with_setup
 from mock import patch
 from ming.orm.ormsession import ThreadLocalORMSession
@@ -197,3 +197,27 @@ def test_messages_unknown_lookup():
     m.author_id = ObjectId()  # something new
     assert type(m.author()) == M.User, type(m.author())
     assert m.author() == M.User.anonymous()
+
+
+@with_setup(setUp, tearDown)
+@patch('allura.model.artifact.datetime')
+def test_last_updated(_datetime):
+    c.project.last_updated = datetime(2014, 1, 1)
+    _datetime.utcnow.return_value = datetime(2014, 1, 2)
+    WM.Page(title='TestPage1')
+    ThreadLocalORMSession.flush_all()
+    assert_equal(c.project.last_updated, datetime(2014, 1, 2))
+
+
+@with_setup(setUp, tearDown)
+@patch('allura.model.artifact.datetime')
+def test_last_updated_disabled(_datetime):
+    c.project.last_updated = datetime(2014, 1, 1)
+    _datetime.utcnow.return_value = datetime(2014, 1, 2)
+    try:
+        M.artifact_orm_session._get().skip_last_updated = True
+        WM.Page(title='TestPage1')
+        ThreadLocalORMSession.flush_all()
+        assert_equal(c.project.last_updated, datetime(2014, 1, 1))
+    finally:
+        M.artifact_orm_session._get().skip_last_updated = False

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/43c4bcee/ForgeImporters/forgeimporters/base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 5fbf6e1..848cb38 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -23,6 +23,7 @@ import urllib2
 from collections import defaultdict
 import traceback
 from urlparse import urlparse
+from datetime import datetime
 try:
     from cStringIO import StringIO
 except ImportError:
@@ -117,13 +118,25 @@ def object_from_path(path):
 
 
 @task(notifications_disabled=True)
-def import_tool(importer_path, project_name=None, mount_point=None, mount_label=None, **kw):
+def import_tool(importer_path, project_name=None,
+                mount_point=None, mount_label=None, **kw):
     importer = object_from_path(importer_path)()
     with ImportErrorHandler(importer, project_name, c.project) as handler,\
-            M.session.substitute_extensions(M.artifact_orm_session, [M.session.BatchIndexer]):
-        app = importer.import_tool(
-            c.project, c.user, project_name=project_name,
-            mount_point=mount_point, mount_label=mount_label, **kw)
+            M.session.substitute_extensions(M.artifact_orm_session,
+                                            [M.session.BatchIndexer]):
+        try:
+            M.artifact_orm_session._get().skip_last_updated = True
+            app = importer.import_tool(
+                c.project, c.user, project_name=project_name,
+                mount_point=mount_point, mount_label=mount_label, **kw)
+            # manually update project's last_updated field at the end of the
+            # import instead of it being updated automatically by each artifact
+            # since long-running task can cause stale project data to be saved
+            M.Project.query.update(
+                {'_id': c.project._id},
+                {'$set': {'last_updated': datetime.utcnow()}})
+        finally:
+            M.artifact_orm_session._get().skip_last_updated = False
         M.artifact_orm_session.flush()
         M.session.BatchIndexer.flush()
         if app:

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/43c4bcee/ForgeTracker/forgetracker/tasks.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tasks.py b/ForgeTracker/forgetracker/tasks.py
index 6492d7d..0fdebc5 100644
--- a/ForgeTracker/forgetracker/tasks.py
+++ b/ForgeTracker/forgetracker/tasks.py
@@ -16,6 +16,7 @@
 #       under the License.
 
 import logging
+from datetime import datetime
 
 from pylons import tmpl_context as c
 
@@ -41,4 +42,14 @@ def move_tickets(ticket_ids, destination_tracker_id):
 
 @task
 def bulk_edit(**post_data):
-    c.app.globals.update_tickets(**post_data)
+    try:
+        M.artifact_orm_session._get().skip_last_updated = True
+        c.app.globals.update_tickets(**post_data)
+        # manually update project's last_updated field at the end of the
+        # import instead of it being updated automatically by each artifact
+        # since long-running task can cause stale project data to be saved
+        M.Project.query.update(
+            {'_id': c.project._id},
+            {'$set': {'last_updated': datetime.utcnow()}})
+    finally:
+        M.artifact_orm_session._get().skip_last_updated = False


[15/15] git commit: [#7085] Fixed 500 error on activity feed for users

Posted by jo...@apache.org.
[#7085] Fixed 500 error on activity feed for users

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4f9038c5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4f9038c5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4f9038c5

Branch: refs/heads/cj/7085
Commit: 4f9038c5e4c52c0b137bf1936a3f8d55222a6e12
Parents: bfee3bc
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Jan 24 21:17:22 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Mon Feb 3 22:53:16 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/project.py                  |   2 +-
 ForgeActivity/forgeactivity/main.py             |   7 +-
 .../forgeactivity/tests/functional/test_root.py | 231 ++++++++++++++++++-
 3 files changed, 229 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4f9038c5/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index f971293..eaec993 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -228,7 +228,7 @@ class Project(MappedClass, ActivityNode, ActivityObject):
 
     @property
     def activity_name(self):
-        return self.shortname
+        return self.name
 
     @property
     def permissions(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4f9038c5/ForgeActivity/forgeactivity/main.py
----------------------------------------------------------------------
diff --git a/ForgeActivity/forgeactivity/main.py b/ForgeActivity/forgeactivity/main.py
index b4e6e5b..08c0283 100644
--- a/ForgeActivity/forgeactivity/main.py
+++ b/ForgeActivity/forgeactivity/main.py
@@ -132,9 +132,10 @@ class ForgeActivityController(BaseController):
         response.headers['Content-Type'] = ''
         response.content_type = 'application/xml'
         d = {
-            'title': 'Activity for %s' % data['followee'].shortname,
+            'title': 'Activity for %s' % data['followee'].activity_name,
             'link': h.absurl(self.app.url),
-            'description': 'Recent activity for %s' % data['followee'].shortname,
+            'description': 'Recent activity for %s' % (
+                data['followee'].activity_name),
             'language': u'en',
         }
         if request.environ['PATH_INFO'].endswith('.atom'):
@@ -147,7 +148,7 @@ class ForgeActivityController(BaseController):
                                 t.actor.activity_name,
                 t.verb,
                 t.obj.activity_name,
-                ' on %s' % t.target.activity_name if t.target.activity_name else '',
+                ' on %s' % (t.target.activity_name or ''),
             ),
                 link=url,
                 pubdate=t.published,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4f9038c5/ForgeActivity/forgeactivity/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeActivity/forgeactivity/tests/functional/test_root.py b/ForgeActivity/forgeactivity/tests/functional/test_root.py
index 7018f10..93f2eab 100644
--- a/ForgeActivity/forgeactivity/tests/functional/test_root.py
+++ b/ForgeActivity/forgeactivity/tests/functional/test_root.py
@@ -62,10 +62,10 @@ class TestActivityController(TestController):
             "_id": ObjectId("529fa331033c5e6406d8b338"),
             "obj": {
                 "activity_extras": {
-                    "allura_id": "Post:971389ad979eaafa658beb807bf4629d30f5f642.tickets@test.p.domain.net",
+                    "allura_id": "some_id",
                     "summary": "Just wanted to leave a comment on this..."
                 },
-                "activity_url": "/p/test/tickets/_discuss/thread/08e74efd/ed7c/",
+                "activity_url": "/p/test/tickets/34/?limit=25#ed7c",
                 "activity_name": "a comment"
             },
             "target": {
@@ -103,7 +103,7 @@ class TestActivityController(TestController):
          Administrator 1
         </a>
         posted
-        <a href="/p/test/tickets/_discuss/thread/08e74efd/ed7c/">
+        <a href="/p/test/tickets/34/?limit=25#ed7c">
          a comment
         </a>
         on
@@ -134,7 +134,7 @@ class TestActivityController(TestController):
         self.app.get('/u/test-admin/activity/')
         assert director.get_timeline.call_count == 1
         assert director.get_timeline.call_args[0][0].username == 'test-admin'
-        assert director.get_timeline.call_args[1]['actor_only'] == False
+        assert director.get_timeline.call_args[1]['actor_only'] is False
 
     @td.with_tool('u/test-user-1', 'activity')
     @td.with_user_project('test-user-1')
@@ -143,7 +143,7 @@ class TestActivityController(TestController):
         self.app.get('/u/test-user-1/activity/')
         assert director.get_timeline.call_count == 1
         assert director.get_timeline.call_args[0][0].username == 'test-user-1'
-        assert director.get_timeline.call_args[1]['actor_only'] == True
+        assert director.get_timeline.call_args[1]['actor_only'] is True
 
     @td.with_tool('test', 'activity')
     @patch('forgeactivity.main.g.director')
@@ -151,7 +151,7 @@ class TestActivityController(TestController):
         self.app.get('/p/test/activity/')
         assert director.get_timeline.call_count == 1
         assert director.get_timeline.call_args[0][0].shortname == 'test'
-        assert director.get_timeline.call_args[1]['actor_only'] == False
+        assert director.get_timeline.call_args[1]['actor_only'] is False
 
     @td.with_tracker
     @td.with_tool('u/test-user-1', 'activity')
@@ -163,7 +163,8 @@ class TestActivityController(TestController):
         d = {'ticket_form.summary': 'New Ticket'}
         self.app.post('/bugs/save_ticket', params=d)
         orig_create_timeline = g.director.aggregator.create_timeline
-        with patch.object(g.director.aggregator, 'create_timeline') as create_timeline:
+        with patch.object(g.director.aggregator, 'create_timeline') as \
+                create_timeline:
             create_timeline.side_effect = orig_create_timeline
             M.MonQTask.run_ready()
             # 3 aggregations: 1 actor, 1 follower, 1 project
@@ -172,3 +173,219 @@ class TestActivityController(TestController):
             self.app.get('/u/test-admin/activity/')
             self.app.get('/u/test-user-1/activity/')
             assert_equal(create_timeline.call_count, 0)
+
+    @td.with_tool('test', 'activity')
+    @patch('forgeactivity.main.g.director')
+    def test_feed_rss_project(self, director):
+        from activitystream.storage.base import StoredActivity
+        from bson import ObjectId
+        director.get_timeline.return_value = [StoredActivity(**{
+            "_id": ObjectId("529fa331033c5e6406d8b338"),
+            "obj": {
+                "activity_extras": {
+                    "allura_id": "some_id",
+                    "summary": "Just wanted to leave a comment on this..."
+                },
+                "activity_url": "/p/test/tickets/34/?limit=25#ed7c",
+                "activity_name": "a comment"
+            },
+            "target": {
+                "activity_extras": {
+                    "allura_id": "Ticket:529f57a6033c5e5985db2efa",
+                    "summary": "Make activitystream timeline look better"
+                },
+                "activity_url": "/p/test/tickets/34/",
+                "activity_name": "ticket #34"
+            },
+            "actor": {
+                "activity_extras": {
+                    "icon_url": "/u/test-admin/user_icon",
+                    "allura_id": "User:521f96cb033c5e2587adbdff"
+                },
+                "activity_url": "/u/test-admin/",
+                "activity_name": "Administrator 1",
+                "node_id": "User:521f96cb033c5e2587adbdff"
+            },
+            "verb": "posted",
+            "published": dateutil.parser.parse("2013-12-04T21:48:19.817"),
+            "score": 1386193699,
+            "node_id": "Project:527a6584033c5e62126f5a60",
+            "owner_id": "Project:527a6584033c5e62126f5a60"
+        })]
+        r = self.app.get('/p/test/activity/feed.rss')
+        timeline = r.xml.find('channel')
+        assert_equal(1, len(timeline.findall('item')))
+        activity = timeline.find('item')
+        assert_equal(activity.find('pubDate').text,
+                     'Wed, 04 Dec 2013 21:48:19 -0000')
+        assert_equal(activity.find('title').text,
+                     'Administrator 1 posted a comment on ticket #34')
+        assert_equal(activity.find('description').text,
+                     'Just wanted to leave a comment on this...')
+        assert_equal(activity.find('link').text,
+                     'http://localhost/p/test/tickets/34/?limit=25#ed7c')
+
+    @td.with_tool('u/test-user-1', 'activity')
+    @td.with_user_project('test-user-1')
+    @patch('forgeactivity.main.g.director')
+    def test_feed_rss_user(self, director):
+        from activitystream.storage.base import StoredActivity
+        from bson import ObjectId
+        director.get_timeline.return_value = [StoredActivity(**{
+            "_id": ObjectId("529fa331033c5e6406d8b338"),
+            "obj": {
+                "activity_extras": {
+                    "allura_id": "some_id",
+                    "summary": "Just wanted to leave a comment on this..."
+                },
+                "activity_url": "/p/test/tickets/34/?limit=25#ed7c",
+                "activity_name": "a comment"
+            },
+            "target": {
+                "activity_extras": {
+                    "allura_id": "Ticket:529f57a6033c5e5985db2efa",
+                    "summary": "Make activitystream timeline look better"
+                },
+                "activity_url": "/p/test/tickets/34/",
+                "activity_name": "ticket #34"
+            },
+            "actor": {
+                "activity_extras": {
+                    "icon_url": "/u/test-admin/user_icon",
+                    "allura_id": "User:521f96cb033c5e2587adbdff"
+                },
+                "activity_url": "/u/test-admin/",
+                "activity_name": "Administrator 1",
+                "node_id": "User:521f96cb033c5e2587adbdff"
+            },
+            "verb": "posted",
+            "published": dateutil.parser.parse("2013-12-04T21:48:19.817"),
+            "score": 1386193699,
+            "node_id": "Project:527a6584033c5e62126f5a60",
+            "owner_id": "Project:527a6584033c5e62126f5a60"
+        })]
+        r = self.app.get('/u/test-user-1/activity/feed.rss')
+        timeline = r.xml.find('channel')
+        assert_equal(1, len(timeline.findall('item')))
+        activity = timeline.find('item')
+        assert_equal(activity.find('pubDate').text,
+                     'Wed, 04 Dec 2013 21:48:19 -0000')
+        assert_equal(activity.find('title').text,
+                     'Administrator 1 posted a comment on ticket #34')
+        assert_equal(activity.find('description').text,
+                     'Just wanted to leave a comment on this...')
+        assert_equal(activity.find('link').text,
+                     'http://localhost/p/test/tickets/34/?limit=25#ed7c')
+
+    @td.with_tool('test', 'activity')
+    @patch('forgeactivity.main.g.director')
+    def test_feed_atom_project(self, director):
+        from activitystream.storage.base import StoredActivity
+        from bson import ObjectId
+        director.get_timeline.return_value = [StoredActivity(**{
+            "_id": ObjectId("529fa331033c5e6406d8b338"),
+            "obj": {
+                "activity_extras": {
+                    "allura_id": "some_id",
+                    "summary": "Just wanted to leave a comment on this..."
+                },
+                "activity_url": "/p/test/tickets/34/?limit=25#ed7c",
+                "activity_name": "a comment"
+            },
+            "target": {
+                "activity_extras": {
+                    "allura_id": "Ticket:529f57a6033c5e5985db2efa",
+                    "summary": "Make activitystream timeline look better"
+                },
+                "activity_url": "/p/test/tickets/34/",
+                "activity_name": "ticket #34"
+            },
+            "actor": {
+                "activity_extras": {
+                    "icon_url": "/u/test-admin/user_icon",
+                    "allura_id": "User:521f96cb033c5e2587adbdff"
+                },
+                "activity_url": "/u/test-admin/",
+                "activity_name": "Administrator 1",
+                "node_id": "User:521f96cb033c5e2587adbdff"
+            },
+            "verb": "posted",
+            "published": dateutil.parser.parse("2013-12-04T21:48:19.817"),
+            "score": 1386193699,
+            "node_id": "Project:527a6584033c5e62126f5a60",
+            "owner_id": "Project:527a6584033c5e62126f5a60"
+        })]
+        r = self.app.get('/p/test/activity/feed.atom')
+        timeline = r.xml
+        assert_equal(1, len(timeline.findall(
+            '{http://www.w3.org/2005/Atom}entry')))
+        activity = timeline.find('{http://www.w3.org/2005/Atom}entry')
+        assert_equal(
+            activity.find('{http://www.w3.org/2005/Atom}published').text,
+            '2013-12-04T21:48:19Z')
+        assert_equal(
+            activity.find('{http://www.w3.org/2005/Atom}title').text,
+            'Administrator 1 posted a comment on ticket #34')
+        assert_equal(
+            activity.find('{http://www.w3.org/2005/Atom}summary').text,
+            'Just wanted to leave a comment on this...')
+        assert_equal(
+            activity.find('{http://www.w3.org/2005/Atom}link').get('href'),
+            'http://localhost/p/test/tickets/34/?limit=25#ed7c')
+
+    @td.with_tool('u/test-user-1', 'activity')
+    @td.with_user_project('test-user-1')
+    @patch('forgeactivity.main.g.director')
+    def test_feed_atom_user(self, director):
+        from activitystream.storage.base import StoredActivity
+        from bson import ObjectId
+        director.get_timeline.return_value = [StoredActivity(**{
+            "_id": ObjectId("529fa331033c5e6406d8b338"),
+            "obj": {
+                "activity_extras": {
+                    "allura_id": "some_id",
+                    "summary": "Just wanted to leave a comment on this..."
+                },
+                "activity_url": "/p/test/tickets/34/?limit=25#ed7c",
+                "activity_name": "a comment"
+            },
+            "target": {
+                "activity_extras": {
+                    "allura_id": "Ticket:529f57a6033c5e5985db2efa",
+                    "summary": "Make activitystream timeline look better"
+                },
+                "activity_url": "/p/test/tickets/34/",
+                "activity_name": "ticket #34"
+            },
+            "actor": {
+                "activity_extras": {
+                    "icon_url": "/u/test-admin/user_icon",
+                    "allura_id": "User:521f96cb033c5e2587adbdff"
+                },
+                "activity_url": "/u/test-admin/",
+                "activity_name": "Administrator 1",
+                "node_id": "User:521f96cb033c5e2587adbdff"
+            },
+            "verb": "posted",
+            "published": dateutil.parser.parse("2013-12-04T21:48:19.817"),
+            "score": 1386193699,
+            "node_id": "Project:527a6584033c5e62126f5a60",
+            "owner_id": "Project:527a6584033c5e62126f5a60"
+        })]
+        r = self.app.get('/u/test-user-1/activity/feed.atom')
+        timeline = r.xml
+        assert_equal(1, len(timeline.findall(
+            '{http://www.w3.org/2005/Atom}entry')))
+        activity = timeline.find('{http://www.w3.org/2005/Atom}entry')
+        assert_equal(
+            activity.find('{http://www.w3.org/2005/Atom}published').text,
+            '2013-12-04T21:48:19Z')
+        assert_equal(
+            activity.find('{http://www.w3.org/2005/Atom}title').text,
+            'Administrator 1 posted a comment on ticket #34')
+        assert_equal(
+            activity.find('{http://www.w3.org/2005/Atom}summary').text,
+            'Just wanted to leave a comment on this...')
+        assert_equal(
+            activity.find('{http://www.w3.org/2005/Atom}link').get('href'),
+            'http://localhost/p/test/tickets/34/?limit=25#ed7c')


[08/15] git commit: [#6893] ticket:507 Rename variable to something more generic

Posted by jo...@apache.org.
[#6893] ticket:507 Rename variable to something more generic


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/50fb9ef1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/50fb9ef1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/50fb9ef1

Branch: refs/heads/cj/7085
Commit: 50fb9ef15678a3ff4d2ba63a552ad47904dec4b9
Parents: 208280f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Jan 27 12:11:09 2014 +0200
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Jan 29 22:11:17 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/widgets/resources/js/combobox.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/50fb9ef1/Allura/allura/lib/widgets/resources/js/combobox.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/combobox.js b/Allura/allura/lib/widgets/resources/js/combobox.js
index 9a20601..4a808d7 100644
--- a/Allura/allura/lib/widgets/resources/js/combobox.js
+++ b/Allura/allura/lib/widgets/resources/js/combobox.js
@@ -39,18 +39,18 @@
       function populateSelect(data) {
         select.children('option').remove();
         $('<option></option>').val('').appendTo(select);
-        var cur_user_in_data = false;
+        var selected_option_present = false;
         for (var i = 0; i < data.options.length; i++) {
           var label = data.options[i].label,
               value = data.options[i].value;
           var option = $('<option>' + label + '</option>').val(value);
           if (selected.val() === value) {
             option.attr('selected', 'selected');  // select initial value, if any
-            cur_user_in_data = true;
+            selected_option_present = true;
           }
           option.appendTo(select);
         }
-        if (!cur_user_in_data) {
+        if (!selected_option_present) {
           selected.attr('selected', 'selected');
           selected.appendTo(select);
         }


[11/15] git commit: [#7118] Added validation to confirm GitHub project exists and is readable

Posted by jo...@apache.org.
[#7118] Added validation to confirm GitHub project exists and is readable

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/38c10a68
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/38c10a68
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/38c10a68

Branch: refs/heads/cj/7085
Commit: 38c10a6890a37730f98ff880193a4970e5d6919d
Parents: 5bc685d
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Jan 30 21:14:26 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Jan 30 22:55:24 2014 +0000

----------------------------------------------------------------------
 .../forgeimporters/github/__init__.py           | 27 ++++++++++++++++++++
 ForgeImporters/forgeimporters/github/code.py    |  8 ++++--
 ForgeImporters/forgeimporters/github/project.py | 15 +++++------
 .../forgeimporters/github/tests/test_code.py    | 18 +++++++++----
 .../forgeimporters/github/tests/test_tracker.py |  9 +++++--
 .../forgeimporters/github/tests/test_wiki.py    | 11 ++++++--
 ForgeImporters/forgeimporters/github/tracker.py | 14 +++++++---
 ForgeImporters/forgeimporters/github/wiki.py    |  8 ++++--
 .../forgeimporters/google/__init__.py           |  8 +++---
 .../tests/github/test_extractor.py              |  7 +++++
 10 files changed, 97 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/38c10a68/ForgeImporters/forgeimporters/github/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index 2d4e85c..0f17e0b 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -26,12 +26,35 @@ from tg import config, session, redirect, request, expose
 from tg.decorators import without_trailing_slash
 from pylons import tmpl_context as c
 from requests_oauthlib import OAuth2Session
+import requests
+from formencode import validators as fev
 
 from forgeimporters import base
 
 log = logging.getLogger(__name__)
 
 
+class GitHubProjectNameValidator(fev.FancyValidator):
+    not_empty = True
+    messages = {
+        'invalid': 'Valid symbols are: letters, numbers, dashes, '
+                   'underscores and periods',
+        'unavailable': 'This project is unavailable for import',
+    }
+
+    def _to_python(self, value, state=None):
+        user_name = state.full_dict.get('user_name', '')
+        user_name = state.full_dict.get('gh_user_name', user_name).strip()
+        project_name = value.strip()
+        full_project_name = '%s/%s' % (user_name, project_name)
+        if not re.match(r'^[a-zA-Z0-9-_.]+$', project_name):
+            raise fev.Invalid(self.message('invalid', state), value, state)
+
+        if not GitHubProjectExtractor(full_project_name).check_readable():
+            raise fev.Invalid(self.message('unavailable', state), value, state)
+        return project_name
+
+
 class GitHubProjectExtractor(base.ProjectExtractor):
     PAGE_MAP = {
         'project_info': 'https://api.github.com/repos/{project_name}',
@@ -83,6 +106,10 @@ class GitHubProjectExtractor(base.ProjectExtractor):
             return self.urlopen(url, **kw)
         return resp
 
+    def check_readable(self):
+        resp = requests.head(self.get_page_url('project_info'))
+        return resp.status_code == 200
+
     def get_next_page_url(self, link):
         if not link:
             return

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/38c10a68/ForgeImporters/forgeimporters/github/code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/code.py b/ForgeImporters/forgeimporters/github/code.py
index ede36b4..710e868 100644
--- a/ForgeImporters/forgeimporters/github/code.py
+++ b/ForgeImporters/forgeimporters/github/code.py
@@ -39,12 +39,16 @@ from forgeimporters.base import (
     ToolImporter,
     ToolImportForm,
 )
-from forgeimporters.github import GitHubProjectExtractor, GitHubOAuthMixin
+from forgeimporters.github import (
+    GitHubProjectExtractor,
+    GitHubOAuthMixin,
+    GitHubProjectNameValidator,
+)
 
 
 class GitHubRepoImportForm(ToolImportForm):
-    gh_project_name = fev.UnicodeString(not_empty=True)
     gh_user_name = fev.UnicodeString(not_empty=True)
+    gh_project_name = GitHubProjectNameValidator()
 
 
 class GitHubRepoImportController(BaseController, GitHubOAuthMixin):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/38c10a68/ForgeImporters/forgeimporters/github/project.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/project.py b/ForgeImporters/forgeimporters/github/project.py
index fc7247b..003adae 100644
--- a/ForgeImporters/forgeimporters/github/project.py
+++ b/ForgeImporters/forgeimporters/github/project.py
@@ -24,20 +24,19 @@ from tg.decorators import with_trailing_slash
 
 from allura.lib.decorators import require_post
 
-from .. import base
-from . import tasks
-from . import GitHubOAuthMixin
+from forgeimporters import base
+from forgeimporters.github import (
+    tasks,
+    GitHubOAuthMixin,
+    GitHubProjectNameValidator,
+)
 
 
 log = logging.getLogger(__name__)
 
 
 class GitHubProjectForm(base.ProjectImportForm):
-    project_name = fev.Regex(r'^[a-zA-Z0-9-_.]+$',
-                             not_empty=True,
-                             messages={
-                                 'invalid': 'Valid symbols are: letters, numbers, dashes, underscores and periods',
-                             })
+    project_name = GitHubProjectNameValidator()
 
 
 class GitHubProjectImporter(base.ProjectImporter, GitHubOAuthMixin):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/38c10a68/ForgeImporters/forgeimporters/github/tests/test_code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_code.py b/ForgeImporters/forgeimporters/github/tests/test_code.py
index 8fa6a2f..bb8ed25 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_code.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_code.py
@@ -75,8 +75,10 @@ class TestGitHubImportController(TestController, TestCase):
         self.assertIsNotNone(r.html.find(attrs=dict(name="mount_point")))
 
     @with_git
+    @patch('forgeimporters.github.requests')
     @patch('forgeimporters.base.import_tool')
-    def test_create(self, import_tool):
+    def test_create(self, import_tool, requests):
+        requests.head.return_value.status_code = 200
         params = dict(
             gh_user_name='spooky',
             gh_project_name='poop',
@@ -84,11 +86,13 @@ class TestGitHubImportController(TestController, TestCase):
             mount_point='mymount',
         )
         r = self.app.post(
-            '/p/{}/admin/ext/import/github-repo/create'.format(test_project_with_repo),
+            '/p/{}/admin/ext/import/github-repo/create'.format(
+                test_project_with_repo),
             params,
             status=302)
         self.assertEqual(
-            r.location, 'http://localhost/p/{}/admin/'.format(test_project_with_repo))
+            r.location, 'http://localhost/p/{}/admin/'.format(
+                test_project_with_repo))
         self.assertEqual(
             u'mymount', import_tool.post.call_args[1]['mount_point'])
         self.assertEqual(
@@ -96,10 +100,13 @@ class TestGitHubImportController(TestController, TestCase):
         self.assertEqual(
             u'poop', import_tool.post.call_args[1]['project_name'])
         self.assertEqual(u'spooky', import_tool.post.call_args[1]['user_name'])
+        self.assertEqual(requests.head.call_count, 1)
 
     @with_git
+    @patch('forgeimporters.github.requests')
     @patch('forgeimporters.base.import_tool')
-    def test_create_limit(self, import_tool):
+    def test_create_limit(self, import_tool, requests):
+        requests.head.return_value.status_code = 200
         project = M.Project.query.get(shortname=test_project_with_repo)
         project.set_tool_data('GitHubRepoImporter', pending=1)
         ThreadLocalORMSession.flush_all()
@@ -110,7 +117,8 @@ class TestGitHubImportController(TestController, TestCase):
             mount_point='mymount',
         )
         r = self.app.post(
-            '/p/{}/admin/ext/import/github-repo/create'.format(test_project_with_repo),
+            '/p/{}/admin/ext/import/github-repo/create'.format(
+                test_project_with_repo),
             params,
             status=302).follow()
         self.assertIn('Please wait and try again', r)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/38c10a68/ForgeImporters/forgeimporters/github/tests/test_tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_tracker.py b/ForgeImporters/forgeimporters/github/tests/test_tracker.py
index 72e1148..ba09ece 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_tracker.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_tracker.py
@@ -45,8 +45,10 @@ class TestGitHubTrackerImportController(TestController, TestCase):
         self.assertIsNotNone(r.html.find(attrs=dict(name='mount_point')))
 
     @with_tracker
+    @patch('forgeimporters.github.requests')
     @patch('forgeimporters.base.import_tool')
-    def test_create(self, import_tool):
+    def test_create(self, import_tool, requests):
+        requests.head.return_value.status_code = 200
         params = dict(
             gh_user_name='spooky',
             gh_project_name='mulder',
@@ -62,10 +64,13 @@ class TestGitHubTrackerImportController(TestController, TestCase):
         self.assertEqual(
             u'mulder', import_tool.post.call_args[1]['project_name'])
         self.assertEqual(u'spooky', import_tool.post.call_args[1]['user_name'])
+        self.assertEqual(requests.head.call_count, 1)
 
     @with_tracker
+    @patch('forgeimporters.github.requests')
     @patch('forgeimporters.base.import_tool')
-    def test_create_limit(self, import_tool):
+    def test_create_limit(self, import_tool, requests):
+        requests.head.return_value.status_code = 200
         p = M.Project.query.get(shortname=test_project_with_tracker)
         p.set_tool_data('GitHubTrackerImporter', pending=1)
         ThreadLocalORMSession.flush_all()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/38c10a68/ForgeImporters/forgeimporters/github/tests/test_wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tests/test_wiki.py b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
index f231f49..50e7278 100644
--- a/ForgeImporters/forgeimporters/github/tests/test_wiki.py
+++ b/ForgeImporters/forgeimporters/github/tests/test_wiki.py
@@ -538,8 +538,10 @@ class TestGitHubWikiImportController(TestController, TestCase):
             r.html.find(attrs=dict(name='tool_option', value='import_history')))
 
     @with_wiki
+    @patch('forgeimporters.github.requests')
     @patch('forgeimporters.base.import_tool')
-    def test_create(self, import_tool):
+    def test_create(self, import_tool, requests):
+        requests.head.return_value.status_code = 200
         params = dict(
             gh_user_name='spooky',
             gh_project_name='mulder',
@@ -555,8 +557,10 @@ class TestGitHubWikiImportController(TestController, TestCase):
         self.assertEqual(u'mulder', args['project_name'])
         self.assertEqual(u'spooky', args['user_name'])
         self.assertEqual(u'import_history', args['tool_option'])
+        self.assertEqual(requests.head.call_count, 1)
 
         # without history
+        requests.head.reset_mock()
         params.pop('tool_option')
         r = self.app.post(self.url + 'create', params, status=302)
         self.assertEqual(r.location, 'http://localhost/p/%s/admin/' %
@@ -567,10 +571,13 @@ class TestGitHubWikiImportController(TestController, TestCase):
         self.assertEqual(u'mulder', args['project_name'])
         self.assertEqual(u'spooky', args['user_name'])
         self.assertEqual(u'', args['tool_option'])
+        self.assertEqual(requests.head.call_count, 1)
 
     @with_wiki
+    @patch('forgeimporters.github.requests')
     @patch('forgeimporters.base.import_tool')
-    def test_create_limit(self, import_tool):
+    def test_create_limit(self, import_tool, requests):
+        requests.head.return_value.status_code = 200
         p = M.Project.query.get(shortname=test_project_with_wiki)
         p.set_tool_data('GitHubWikiImporter', pending=1)
         ThreadLocalORMSession.flush_all()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/38c10a68/ForgeImporters/forgeimporters/github/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tracker.py b/ForgeImporters/forgeimporters/github/tracker.py
index 3af1517..fff88f6 100644
--- a/ForgeImporters/forgeimporters/github/tracker.py
+++ b/ForgeImporters/forgeimporters/github/tracker.py
@@ -46,11 +46,17 @@ from ming.orm import session, ThreadLocalORMSession
 from pylons import tmpl_context as c
 from pylons import app_globals as g
 
-from . import GitHubProjectExtractor, GitHubOAuthMixin
-from ..base import ToolImporter
 from forgetracker.tracker_main import ForgeTrackerApp
 from forgetracker import model as TM
-from forgeimporters.base import ToolImportForm
+from forgeimporters.base import (
+    ToolImportForm,
+    ToolImporter,
+)
+from forgeimporters.github import (
+    GitHubProjectExtractor,
+    GitHubOAuthMixin,
+    GitHubProjectNameValidator,
+)
 from forgeimporters.github.utils import GitHubMarkdownConverter
 
 
@@ -58,7 +64,7 @@ log = logging.getLogger(__name__)
 
 
 class GitHubTrackerImportForm(ToolImportForm):
-    gh_project_name = fev.UnicodeString(not_empty=True)
+    gh_project_name = GitHubProjectNameValidator()
     gh_user_name = fev.UnicodeString(not_empty=True)
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/38c10a68/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 0bd95da..99333f7 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -52,7 +52,11 @@ from forgeimporters.base import (
     ToolImporter,
     ToolImportForm,
 )
-from forgeimporters.github import GitHubProjectExtractor, GitHubOAuthMixin
+from forgeimporters.github import (
+    GitHubProjectExtractor,
+    GitHubOAuthMixin,
+    GitHubProjectNameValidator,
+)
 from forgeimporters.github.utils import GitHubMarkdownConverter
 from forgewiki import model as WM
 from forgewiki.converters import mediawiki2markdown
@@ -71,7 +75,7 @@ except ImportError:
 
 
 class GitHubWikiImportForm(ToolImportForm):
-    gh_project_name = fev.UnicodeString(not_empty=True)
+    gh_project_name = GitHubProjectNameValidator()
     gh_user_name = fev.UnicodeString(not_empty=True)
     tool_option = fev.UnicodeString(if_missing=u'')
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/38c10a68/ForgeImporters/forgeimporters/google/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/google/__init__.py b/ForgeImporters/forgeimporters/google/__init__.py
index 51560f9..aebc596 100644
--- a/ForgeImporters/forgeimporters/google/__init__.py
+++ b/ForgeImporters/forgeimporters/google/__init__.py
@@ -118,7 +118,9 @@ def csv_parser(page):
 class GoogleCodeProjectNameValidator(fev.FancyValidator):
     not_empty = True
     messages = {
-        'invalid': 'Please enter a project URL, or a project name containing only letters, numbers, and dashes.',
+        'invalid': 'Please enter a project URL, or a project name containing '
+                   'only letters, numbers, and dashes.',
+        'unavailable': 'This project is unavailable for import',
     }
 
     def _to_python(self, value, state=None):
@@ -128,10 +130,10 @@ class GoogleCodeProjectNameValidator(fev.FancyValidator):
         else:
             project_name = os.path.basename(url.path.strip('/'))
         if not re.match(r'^[a-z0-9][a-z0-9-]{,61}$', project_name):
-            raise fev.Invalid(self.message('invalid'))
+            raise fev.Invalid(self.message('invalid', state), value, state)
 
         if not GoogleCodeProjectExtractor(project_name).check_readable():
-            raise fev.Invalid('The project "%s" is not avalible for import' % value, value, state)
+            raise fev.Invalid(self.message('unavailable', state), value, state)
         return project_name
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/38c10a68/ForgeImporters/forgeimporters/tests/github/test_extractor.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/github/test_extractor.py b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
index a8ae0a5..8b81f88 100644
--- a/ForgeImporters/forgeimporters/tests/github/test_extractor.py
+++ b/ForgeImporters/forgeimporters/tests/github/test_extractor.py
@@ -213,3 +213,10 @@ class TestGitHubProjectExtractor(TestCase):
             'Rate limit exceeded (10 requests/hour). '
             'Sleeping until 2013-10-25 09:32:02 UTC'
         )
+
+    @patch.object(github.requests, 'head')
+    def test_check_readable(self, head):
+        head.return_value.status_code = 200
+        assert github.GitHubProjectExtractor('my-project').check_readable()
+        head.return_value.status_code = 404
+        assert not github.GitHubProjectExtractor('my-project').check_readable()


[04/15] git commit: [#7103] Fixed test failure

Posted by jo...@apache.org.
[#7103] Fixed test failure

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/b15ef350
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/b15ef350
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/b15ef350

Branch: refs/heads/cj/7085
Commit: b15ef350f92e908556fc4fd15b265b266e5db444
Parents: 43c4bce
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Mon Jan 27 22:08:14 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Mon Jan 27 22:08:14 2014 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/tests/test_base.py | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b15ef350/ForgeImporters/forgeimporters/tests/test_base.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/tests/test_base.py b/ForgeImporters/forgeimporters/tests/test_base.py
index c5aeb68..e93a6b1 100644
--- a/ForgeImporters/forgeimporters/tests/test_base.py
+++ b/ForgeImporters/forgeimporters/tests/test_base.py
@@ -45,10 +45,12 @@ class TestProjectExtractor(TestCase):
         self.assertEqual(r, urlopen.return_value)
 
 
+@mock.patch.object(base, 'datetime')
+@mock.patch.object(base, 'M')
 @mock.patch.object(base, 'object_from_path')
 @mock.patch.object(base, 'c')
 @mock.patch.object(base, 'g')
-def test_import_tool(g, c, object_from_path):
+def test_import_tool(g, c, object_from_path, M, _datetime):
     c.project = mock.Mock(name='project')
     c.user = mock.Mock(name='user')
     object_from_path.return_value = importer = mock.Mock()
@@ -58,11 +60,16 @@ def test_import_tool(g, c, object_from_path):
         'forgeimporters.base.ToolImporter', project_name='project_name',
         mount_point='mount_point', mount_label='mount_label')
     app = importer.return_value.import_tool.return_value
-    importer.return_value.import_tool.assert_called_once_with(c.project,
-                                                              c.user, project_name='project_name', mount_point='mount_point',
-                                                              mount_label='mount_label')
-    g.director.create_activity.assert_called_once_with(c.user, "imported",
-                                                       app.config, related_nodes=[c.project])
+    importer.return_value.import_tool.assert_called_once_with(
+        c.project,
+        c.user, project_name='project_name', mount_point='mount_point',
+        mount_label='mount_label')
+    M.Project.query.update.assert_called_once_with(
+        {'_id': c.project._id},
+        {'$set': {'last_updated': _datetime.utcnow()}})
+    g.director.create_activity.assert_called_once_with(
+        c.user, "imported",
+        app.config, related_nodes=[c.project])
     g.post_event.assert_called_once_with(
         'import_tool_task_succeeded',
         'source',


[06/15] git commit: [#7109] use user.url() instead of constructing /u/username manually; add sender's name

Posted by jo...@apache.org.
[#7109] use user.url() instead of constructing /u/username manually; add sender's name

Using 'user' variable instead of 'username' also allows for more flexibility with
anyone that overrides this template for customizations.


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/782f0c05
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/782f0c05
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/782f0c05

Branch: refs/heads/cj/7085
Commit: 782f0c05e618e9d5ac164a221b53d01a3e985f3b
Parents: 036905c
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Jan 28 16:26:18 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Jan 29 22:04:15 2014 +0000

----------------------------------------------------------------------
 Allura/allura/ext/user_profile/templates/message.html | 2 +-
 Allura/allura/model/auth.py                           | 6 +++++-
 Allura/allura/tests/functional/test_user_profile.py   | 4 ++--
 3 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/782f0c05/Allura/allura/ext/user_profile/templates/message.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/user_profile/templates/message.html b/Allura/allura/ext/user_profile/templates/message.html
index f06e1d4..d354b4d 100644
--- a/Allura/allura/ext/user_profile/templates/message.html
+++ b/Allura/allura/ext/user_profile/templates/message.html
@@ -20,5 +20,5 @@
 
 ---
 
-This message was sent to you via the {{site_name}} web mail form.  You may reply to this message directly, or at {{base_url}}/u/{{username}}/profile/send_message
+This message was sent to you via the {{site_name}} web mail form.  You may reply to this message directly, or send a message to {{user.display_name or user.username}} at {{base_url}}{{user.url()}}profile/send_message
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/782f0c05/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index bac0568..542b1f6 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -415,7 +415,7 @@ class User(MappedClass, ActivityNode, ActivityObject):
             'message_text': message,
             'site_name': config['site_name'],
             'base_url': config['base_url'],
-            'username': c.user.username,
+            'user': c.user,
         }
         allura.tasks.mail_tasks.sendsimplemail.post(
             toaddr=user.get_pref('email_address'),
@@ -588,6 +588,10 @@ class User(MappedClass, ActivityNode, ActivityObject):
         return retval
 
     def url(self):
+        '''
+        Return the URL (relative to root domain) for this user's user-project.
+        This includes any special handling via the Auth Provider to determine the proper user-project name
+        '''
         return '/%s/' % plugin.AuthenticationProvider.get(request).user_project_shortname(self)
 
     @memoize

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/782f0c05/Allura/allura/tests/functional/test_user_profile.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_user_profile.py b/Allura/allura/tests/functional/test_user_profile.py
index 6aa4629..6f01e6a 100644
--- a/Allura/allura/tests/functional/test_user_profile.py
+++ b/Allura/allura/tests/functional/test_user_profile.py
@@ -81,7 +81,7 @@ class TestUserProfile(TestController):
 
         sendsimplemail.post.assert_called_once_with(
             cc=User.by_username('test-admin').get_pref('email_address'),
-            text=u'test message\n\n---\n\nThis message was sent to you via the Allura web mail form.  You may reply to this message directly, or at http://localhost/u/test-admin/profile/send_message\n',
+            text=u'test message\n\n---\n\nThis message was sent to you via the Allura web mail form.  You may reply to this message directly, or send a message to Test Admin at http://localhost/u/test-admin/profile/send_message\n',
             toaddr=User.by_username('test-user').get_pref('email_address'),
             fromaddr=User.by_username('test-admin').get_pref('email_address'),
             reply_to=User.by_username('test-admin').get_pref('email_address'),
@@ -94,7 +94,7 @@ class TestUserProfile(TestController):
 
         sendsimplemail.post.assert_called_once_with(
             cc=None,
-            text=u'test message\n\n---\n\nThis message was sent to you via the Allura web mail form.  You may reply to this message directly, or at http://localhost/u/test-admin/profile/send_message\n',
+            text=u'test message\n\n---\n\nThis message was sent to you via the Allura web mail form.  You may reply to this message directly, or send a message to Test Admin at http://localhost/u/test-admin/profile/send_message\n',
             toaddr=User.by_username('test-user').get_pref('email_address'),
             fromaddr=User.by_username('test-admin').get_pref('email_address'),
             reply_to=User.by_username('test-admin').get_pref('email_address'),


[12/15] git commit: [#7118] Better handling for GitHub wiki import errors

Posted by jo...@apache.org.
[#7118] Better handling for GitHub wiki import errors

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1d8f6c8a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1d8f6c8a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1d8f6c8a

Branch: refs/heads/cj/7085
Commit: 1d8f6c8a087d267ade34262445c9b06680267a46
Parents: 38c10a6
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Jan 30 21:11:11 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Jan 30 22:55:56 2014 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/wiki.py | 22 +++++++++++++++++-----
 requirements-sf.txt                          |  4 ++--
 2 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1d8f6c8a/ForgeImporters/forgeimporters/github/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/wiki.py b/ForgeImporters/forgeimporters/github/wiki.py
index 99333f7..1891da7 100644
--- a/ForgeImporters/forgeimporters/github/wiki.py
+++ b/ForgeImporters/forgeimporters/github/wiki.py
@@ -143,14 +143,15 @@ class GitHubWikiImporter(ToolImporter):
     available_pages = []
 
     def import_tool(
-            self, project, user, project_name=None, mount_point=None, mount_label=None, user_name=None,
-            tool_option=None, **kw):
+            self, project, user, project_name=None, mount_point=None,
+            mount_label=None, user_name=None, tool_option=None, **kw):
         """ Import a GitHub wiki into a new Wiki Allura tool.
 
         """
         project_name = "%s/%s" % (user_name, project_name)
         extractor = GitHubProjectExtractor(project_name, user=user)
-        if not extractor.has_wiki():
+        wiki_avail = extractor.has_wiki()
+        if not wiki_avail:
             return
 
         self.github_wiki_url = extractor.get_page_url(
@@ -171,8 +172,19 @@ class GitHubWikiImporter(ToolImporter):
         try:
             M.session.artifact_orm_session._get().skip_mod_date = True
             with h.push_config(c, app=self.app):
-                self.import_pages(
-                    extractor.get_page_url('wiki_url'), history=with_history)
+                try:
+                    wiki_url = extractor.get_page_url('wiki_url')
+                    self.import_pages(wiki_url, history=with_history)
+                except git.GitCommandError:
+                    log.error(
+                        'Unable to clone GitHub wiki: '
+                        'wiki_url=%s; '
+                        'wiki_avail=%s; '
+                        'avail_url=%s',
+                        wiki_url, wiki_avail,
+                        extractor.get_page_url('project_info'),
+                        exc_info=True)
+                    raise
             ThreadLocalORMSession.flush_all()
             M.AuditLog.log(
                 'import tool %s from %s on %s' % (

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1d8f6c8a/requirements-sf.txt
----------------------------------------------------------------------
diff --git a/requirements-sf.txt b/requirements-sf.txt
index 8c6c040..b54c0c0 100644
--- a/requirements-sf.txt
+++ b/requirements-sf.txt
@@ -24,9 +24,9 @@ TracWikiImporter==0.3.6
 MediawikiImporter==0.0.2
 Unidecode==0.04.14
 
-# use version built from https://github.com/johnsca/GitPython/commits/tv/6000
+# use version built from https://github.com/johnsca/GitPython/tree/sf-master
 # for unmerged fixes for [#5411], [#6000], and [#6078]
-GitPython==0.3.2.RC1-20131017
+GitPython==0.3.2.RC1-20140130
 
 WebError==0.10.3-20130423
 


[13/15] git commit: [#7118] Added check for disabled tracker in GitHub import

Posted by jo...@apache.org.
[#7118] Added check for disabled tracker in GitHub import

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/a92b8e00
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a92b8e00
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a92b8e00

Branch: refs/heads/cj/7085
Commit: a92b8e00474ad05dd66d1631a70259cdb6449bba
Parents: 1d8f6c8
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Jan 30 23:18:54 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Jan 30 23:18:54 2014 +0000

----------------------------------------------------------------------
 ForgeImporters/forgeimporters/github/__init__.py | 3 +++
 ForgeImporters/forgeimporters/github/tracker.py  | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a92b8e00/ForgeImporters/forgeimporters/github/__init__.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/__init__.py b/ForgeImporters/forgeimporters/github/__init__.py
index 0f17e0b..434e639 100644
--- a/ForgeImporters/forgeimporters/github/__init__.py
+++ b/ForgeImporters/forgeimporters/github/__init__.py
@@ -173,6 +173,9 @@ class GitHubProjectExtractor(base.ProjectExtractor):
     def has_wiki(self):
         return self.get_page('project_info').get('has_wiki')
 
+    def has_tracker(self):
+        return self.get_page('project_info').get('has_issues')
+
 
 class GitHubOAuthMixin(object):
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a92b8e00/ForgeImporters/forgeimporters/github/tracker.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/tracker.py b/ForgeImporters/forgeimporters/github/tracker.py
index fff88f6..4295f2d 100644
--- a/ForgeImporters/forgeimporters/github/tracker.py
+++ b/ForgeImporters/forgeimporters/github/tracker.py
@@ -115,6 +115,9 @@ class GitHubTrackerImporter(ToolImporter):
                     mount_label=None, **kw):
         import_id_converter = ImportIdConverter.get()
         project_name = '%s/%s' % (kw['user_name'], project_name)
+        extractor = GitHubProjectExtractor(project_name, user=user)
+        if not extractor.has_tracker():
+            return
         app = project.install_app('tickets', mount_point, mount_label,
                                   EnableVoting=False,
                                   open_status_names='open',
@@ -127,7 +130,6 @@ class GitHubTrackerImporter(ToolImporter):
         self.github_markdown_converter = GitHubMarkdownConverter(
             kw['user_name'], project_name)
         ThreadLocalORMSession.flush_all()
-        extractor = GitHubProjectExtractor(project_name, user=user)
         try:
             M.session.artifact_orm_session._get().skip_mod_date = True
             with h.push_config(c, user=M.User.anonymous(), app=app):


[14/15] git commit: [#7096] Convert email msg to unicode before saving to mongo

Posted by jo...@apache.org.
[#7096] Convert email msg to unicode before saving to mongo

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/bfee3bc7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/bfee3bc7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/bfee3bc7

Branch: refs/heads/cj/7085
Commit: bfee3bc78629d5e48aca0c20e207f24e60debd2c
Parents: a92b8e0
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Fri Jan 31 17:54:25 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Jan 31 18:07:47 2014 +0000

----------------------------------------------------------------------
 Allura/allura/command/smtp_server.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bfee3bc7/Allura/allura/command/smtp_server.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/smtp_server.py b/Allura/allura/command/smtp_server.py
index a055d8a..eb2a98f 100644
--- a/Allura/allura/command/smtp_server.py
+++ b/Allura/allura/command/smtp_server.py
@@ -24,6 +24,7 @@ from paste.script import command
 
 import allura.tasks
 from allura.command import base
+from allura.lib import helpers as h
 
 from paste.deploy.converters import asint
 
@@ -54,7 +55,8 @@ class MailServer(smtpd.SMTPServer):
             base.log.info('Msg Received from %s for %s', mailfrom, rcpttos)
             base.log.info(' (%d bytes)', len(data))
             allura.tasks.mail_tasks.route_email.post(
-                peer=peer, mailfrom=mailfrom, rcpttos=rcpttos, data=data)
+                peer=peer, mailfrom=mailfrom, rcpttos=rcpttos,
+                data=h.really_unicode(data))
             base.log.info('Msg passed along')
         except Exception:
             base.log.exception('Error handling msg')