You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/09/09 16:02:39 UTC
[4/6] git commit: [#6533] ticket:422 starting github code importer
into project
[#6533] ticket:422 starting github code importer into project
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/df79d597
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/df79d597
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/df79d597
Branch: refs/heads/master
Commit: df79d5975da1bcf4a587ca17bde54069485d6a6e
Parents: 61990e1
Author: Anton Kasyanov <mi...@gmail.com>
Authored: Tue Sep 3 14:11:06 2013 +0300
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Mon Sep 9 14:02:08 2013 +0000
----------------------------------------------------------------------
ForgeImporters/forgeimporters/github/code.py | 56 ++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/df79d597/ForgeImporters/forgeimporters/github/code.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/github/code.py b/ForgeImporters/forgeimporters/github/code.py
index 041a46d..9121f5c 100644
--- a/ForgeImporters/forgeimporters/github/code.py
+++ b/ForgeImporters/forgeimporters/github/code.py
@@ -15,9 +15,13 @@
# specific language governing permissions and limitations
# under the License.
-from pylons import app_globals as g
+import formencode as fe
+from pylons import app_globals as g
+from formencode import validators as fev
+from allura.controllers import BaseController
+from allura.lib import validators as v
from forgeimporters.base import ToolImporter
from forgeimporters.github import GitHubProjectExtractor
@@ -29,6 +33,56 @@ try:
except ImportError:
pass
+@task(notifications_disabled=True)
+def import_tool(**kw):
+ GoogleRepoImporter().import_tool(c.project, c.user, **kw)
+
+
+class GitHubRepoImportForm(fe.schema.Schema):
+ gh_project_name = fev.UnicodeString(not_empty=True)
+ mount_point = fev.UnicodeString()
+ mount_label = fev.UnicodeString()
+
+ def _to_python(self, value, state):
+ value = super(self.__class__, self)._to_python(value, state)
+
+ gh_project_name = value['gh_project_name']
+ mount_point = value['mount_point']
+ try:
+ v.MountPointValidator('git').to_python(mount_point)
+ except fe.Invalid as e:
+ raise fe.Invalid('mount_point:' + str(e), value, state)
+ return value
+
+
+class GitHubRepoImportController(BaseController):
+ def __init__(self):
+ self.importer = GitHubRepoImporter()
+
+ @property
+ def target_app(self):
+ return self.importer.target_app[0]
+
+ @with_trailing_slash
+ @expose('jinja:forgeimporters.google:templates/code/index.html')
+ def index(self, **kw):
+ return dict(importer=self.importer,
+ target_app=self.target_app)
+
+ @without_trailing_slash
+ @expose()
+ @require_post()
+ @validate(GoogleRepoImportForm(), error_handler=index)
+ def create(self, gc_project_name, mount_point, mount_label, **kw):
+ import_tool.post(
+ project_name=gc_project_name,
+ mount_point=mount_point,
+ mount_label=mount_label)
+ flash('Repo import has begun. Your new repo will be available '
+ 'when the import is complete.')
+ redirect(c.project.url() + 'admin/')
+
+
class GitHubRepoImporter(ToolImporter):
target_app = TARGET_APPS