Commit 7b423a55 authored by Jérome Perrin's avatar Jérome Perrin

test_result: update jump to viewvc to support git

parent f649b239
......@@ -30,7 +30,9 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
......@@ -54,7 +56,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ViewVC Revision</string> </value>
<value> <string>VCS Web Interface</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
......@@ -71,7 +73,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/TestResult_jumpViewVCRevision</string> </value>
<value> <string>string:${object_url}/TestResult_viewJumpVCSDialog</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -52,21 +52,79 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
viewvc_url = context.getProperty(\'viewvc_url\', \'http://svn.erp5.org/\')\n
revision = context.getIntIndex()\n
return container.REQUEST.RESPONSE.redirect(\n
\'%s?view=rev&rev=%s\' % (viewvc_url, revision))\n
"Jump to gitlab or gitweb web interface to view commit"\n
\n
portal = context.getPortalObject()\n
test_suite_list = portal.portal_catalog(\n
portal_type=\'Test Suite\',\n
validation_state=(\'validated\', \'invalidated\'),\n
title={\'query\': context.getTitle(), \'key\': \'ExactMatch\'})\n
\n
if not test_suite_list:\n
return []\n
\n
test_suite = sorted(\n
[test_suite.getObject() for test_suite in test_suite_list],\n
key=lambda test_suite: test_suite.getValidationState() == \'validated\')[0]\n
\n
# TODO: make this jump test suite\n
\n
# decode the reference ( ${buildout_section_id}=${number of commits}-${hash},${buildout_section_id}=${number of commits}-${hash}, ... ) \n
repository_dict = {}\n
for repository_string in context.getReference().split(\',\'):\n
repository_code, revision = repository_string.split(\'-\')\n
repository_dict[repository_code.split(\'=\')[0]] = revision\n
\n
\n
result_list = []\n
from Products.PythonScripts.standard import Object\n
\n
def makeVCSLink(repository_url, revision):\n
# https://user:pass@lab.nexedi.cn/user/repo.git -> https://user:pass@lab.nexedi.cn/user/repo/commit/hash\n
if \'lab.nexedi.cn\' in repository_url and repository_url.endswith(\'.git\'):\n
repository_url = repository_url[:-len(\'.git\')]\n
if \'@\' in repository_url: # remove credentials\n
scheme = repository_url.split(\':\')[0] \n
url = \'%s://%s/commit/%s\' % (scheme, repository_url.split(\'@\')[1], revision )\n
else:\n
url = \'%s/commit/%s\' % (repository_url, revision )\n
# gitweb for git.erp5.org\n
if \'/repos/\' in url:\n
url = url.replace(\'/repos/\', \'/gitweb/\')\n
url = url.replace(\'/commit/\', \'/commitdiff/\')\n
\n
def getListItemUrl(*args, **kw):\n
return url\n
\n
return Object(\n
uid=\'new_\',\n
getUid=lambda: \'new_\',\n
getListItemUrl=getListItemUrl,\n
repository=repository_url,\n
revision=revision)\n
\n
for repository in test_suite.contentValues(portal_type=\'Test Suite Repository\'):\n
result_list.append(\n
makeVCSLink(\n
repository.getProperty(\'git_url\'),\n
repository_dict[repository.getProperty(\'buildout_section_id\')]))\n
\n
if len(result_list) == 1:\n
from zExceptions import Redirect\n
raise Redirect(result_list[0].getListItemUrl())\n
\n
return result_list\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
<value> <string>*args, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TestResult_jumpViewVCRevision</string> </value>
<value> <string>TestResult_getJumpVCSResultList</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>TestResult_view</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>listbox</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_title</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TestResult_viewJumpVCSDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>TestResult_viewJumpVCSDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>VCS Web Interface</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment