---
mods/git.py | 62 +++++++++++++++++++++++++++++------------------------
1 file changed, 34 insertions(+), 28 deletions(-)
diff --git a/mods/git.py b/mods/git.py
index 1f22f2e..7d33566 100644
--- a/mods/git.py
+++ b/mods/git.py
@@ -122,7 +122,13 @@ class GitModule(PatchewModule):
else:
git_repo = obj.get_property("git.repo")
git_tag = obj.get_property("git.tag")
- data = {'repo': git_repo, 'tag': 'refs/tags/' + git_tag}
+ git_url = obj.get_property("git.url")
+ data = {}
+ if git_repo and git_tag:
+ data['repo'] = git_repo
+ data['tag'] = 'refs/tags/' + git_tag
+ if git_url:
+ data['url'] = git_url
status = 'success'
log_url = reverse("git-log", kwargs={'series': obj.message_id})
else:
@@ -130,30 +136,19 @@ class GitModule(PatchewModule):
log_url = None
results.append(Result(name='git', obj=obj, status=status,
log=log, log_url=log_url, data=data,
- request=request))
+ request=request, renderer=self))
def prepare_message_hook(self, request, message, detailed):
if not message.is_series_head:
return
- l = message.get_property("git.apply-log")
- if l:
- failed = message.get_property("git.apply-failed")
- log_url = reverse("git-log",
- kwargs={"series": message.message_id})
- html_log_url = log_url + "?html=1"
- colorbox_a = format_html('<a class="cbox-log" data-link="{}" href="{}">apply log</a>',
- html_log_url, log_url)
- if failed:
+ if message.get_property("git.apply-log"):
+ if message.get_property("git.apply-failed"):
title = "Failed in applying to current master"
message.status_tags.append({
"title": title,
"type": "default",
"char": "G",
})
- message.extra_status.append({
- "kind": "alert",
- "html": format_html('{} ({})', title, colorbox_a),
- })
else:
git_url = message.get_property("git.url")
git_repo = message.get_property("git.repo")
@@ -165,25 +160,12 @@ class GitModule(PatchewModule):
"type": "info",
"char": "G",
})
- if git_repo and git_tag:
- message.extra_status.append({
- "kind": "good",
- "html": format_html('Patches applied successfully (<a href="{}">tree</a>, {}).<br/><samp>git fetch {} {}</samp>',
- git_url, colorbox_a, git_repo, git_tag),
- })
else:
message.status_tags.append({
"title": format_html("Patches applied successfully"),
"type": "info",
"char": "G",
})
- message.extra_status.append({
- "kind": "good",
- "html": format_html('Patches applied successfully ({})',
- colorbox_a),
- "extra": colorbox_div,
- "id": "gitlog"
- })
if request.user.is_authenticated:
if message.get_property("git.apply-failed") != None or \
message.get_property("git.need-apply") == None:
@@ -195,6 +177,30 @@ class GitModule(PatchewModule):
"class": "warning",
})
+ def render_result(self, result):
+ if result.status == 'pending':
+ return None
+
+ if result.log_url is not None:
+ html_log_url = result.log_url + "?html=1"
+ colorbox_a = format_html('<a class="cbox-log" data-link="{}" href="{}">apply log</a>',
+ html_log_url, result.log_url)
+ if result.status == 'failed':
+ return format_html('Failed in applying to current master ({})', title, colorbox_a)
+ else:
+ if 'url' in result.data:
+ s = format_html('<a href="{}">tree</a>, {}', result.data['url'], colorbox_a)
+ else:
+ s = colorbox_a
+ s = format_html('Patches applied successfully ({})', s)
+ if 'repo' in result.data and 'tag' in result.data:
+ git_repo = result.data['repo']
+ git_tag = result.data['tag']
+ if git_tag.startswith('refs/tags/'):
+ git_tag = git_tag[5:]
+ s += format_html('<br/><samp>git fetch {} {}</samp>', git_repo, git_tag)
+ return s
+
def prepare_project_hook(self, request, project):
if not project.maintained_by(request.user):
return
--
2.17.0
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel
On Mon, 04/23 14:14, Paolo Bonzini wrote: > --- > mods/git.py | 62 +++++++++++++++++++++++++++++------------------------ > 1 file changed, 34 insertions(+), 28 deletions(-) > > diff --git a/mods/git.py b/mods/git.py > index 1f22f2e..7d33566 100644 > --- a/mods/git.py > +++ b/mods/git.py > @@ -122,7 +122,13 @@ class GitModule(PatchewModule): > else: > git_repo = obj.get_property("git.repo") > git_tag = obj.get_property("git.tag") > - data = {'repo': git_repo, 'tag': 'refs/tags/' + git_tag} > + git_url = obj.get_property("git.url") > + data = {} > + if git_repo and git_tag: > + data['repo'] = git_repo > + data['tag'] = 'refs/tags/' + git_tag > + if git_url: > + data['url'] = git_url > status = 'success' > log_url = reverse("git-log", kwargs={'series': obj.message_id}) > else: > @@ -130,30 +136,19 @@ class GitModule(PatchewModule): > log_url = None > results.append(Result(name='git', obj=obj, status=status, > log=log, log_url=log_url, data=data, > - request=request)) > + request=request, renderer=self)) > > def prepare_message_hook(self, request, message, detailed): > if not message.is_series_head: > return > - l = message.get_property("git.apply-log") > - if l: > - failed = message.get_property("git.apply-failed") > - log_url = reverse("git-log", > - kwargs={"series": message.message_id}) > - html_log_url = log_url + "?html=1" > - colorbox_a = format_html('<a class="cbox-log" data-link="{}" href="{}">apply log</a>', > - html_log_url, log_url) > - if failed: > + if message.get_property("git.apply-log"): > + if message.get_property("git.apply-failed"): > title = "Failed in applying to current master" > message.status_tags.append({ > "title": title, > "type": "default", > "char": "G", > }) > - message.extra_status.append({ > - "kind": "alert", > - "html": format_html('{} ({})', title, colorbox_a), > - }) > else: > git_url = message.get_property("git.url") > git_repo = message.get_property("git.repo") > @@ -165,25 +160,12 @@ class GitModule(PatchewModule): > "type": "info", > "char": "G", > }) > - if git_repo and git_tag: > - message.extra_status.append({ > - "kind": "good", > - "html": format_html('Patches applied successfully (<a href="{}">tree</a>, {}).<br/><samp>git fetch {} {}</samp>', > - git_url, colorbox_a, git_repo, git_tag), > - }) > else: > message.status_tags.append({ > "title": format_html("Patches applied successfully"), > "type": "info", > "char": "G", > }) > - message.extra_status.append({ > - "kind": "good", > - "html": format_html('Patches applied successfully ({})', > - colorbox_a), > - "extra": colorbox_div, > - "id": "gitlog" > - }) > if request.user.is_authenticated: > if message.get_property("git.apply-failed") != None or \ > message.get_property("git.need-apply") == None: > @@ -195,6 +177,30 @@ class GitModule(PatchewModule): > "class": "warning", > }) > > + def render_result(self, result): > + if result.status == 'pending': > + return None > + > + if result.log_url is not None: > + html_log_url = result.log_url + "?html=1" > + colorbox_a = format_html('<a class="cbox-log" data-link="{}" href="{}">apply log</a>', > + html_log_url, result.log_url) > + if result.status == 'failed': > + return format_html('Failed in applying to current master ({})', title, colorbox_a) > + else: > + if 'url' in result.data: result.data is None here if git.apply-failed: Internal Server Error: /QEMU/717b8178-5a4e-49bd-8dc5-8cb5ef50aa12@SHWDEOPENPSI011.local/ Traceback (most recent call last): File "/stor/work/patchew/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/stor/work/patchew/venv/lib64/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/stor/work/patchew/venv/lib64/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/stor/work/patchew/www/views.py", line 273, in view_series_detail results=prepare_results(request, s), File "/stor/work/patchew/www/views.py", line 100, in prepare_results html = result.render() File "/stor/work/patchew/api/models.py", line 618, in render return self.renderer.render_result(self) File "/stor/work/patchew/mods/git.py", line 191, in render_result if 'url' in result.data: TypeError: argument of type 'NoneType' is not iterable Fam > + s = format_html('<a href="{}">tree</a>, {}', result.data['url'], colorbox_a) > + else: > + s = colorbox_a > + s = format_html('Patches applied successfully ({})', s) > + if 'repo' in result.data and 'tag' in result.data: > + git_repo = result.data['repo'] > + git_tag = result.data['tag'] > + if git_tag.startswith('refs/tags/'): > + git_tag = git_tag[5:] > + s += format_html('<br/><samp>git fetch {} {}</samp>', git_repo, git_tag) > + return s > + > def prepare_project_hook(self, request, project): > if not project.maintained_by(request.user): > return > -- > 2.17.0 > > > _______________________________________________ > Patchew-devel mailing list > Patchew-devel@redhat.com > https://www.redhat.com/mailman/listinfo/patchew-devel _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel
On 03/05/2018 11:20, Fam Zheng wrote: >> + if result.status == 'failed': >> + return format_html('Failed in applying to current master ({})', title, colorbox_a) >> + else: >> + if 'url' in result.data: > result.data is None here if git.apply-failed: Ah, that "failed" must be "failure". It's probably best to make it more "enum"-like by defining RESULT_SUCCESS = 'success' RESULT_FAILURE = 'failure' RESULT_PENDING = 'pending' RESULT_RUNNING = 'running' Paolo > Internal Server Error: /QEMU/717b8178-5a4e-49bd-8dc5-8cb5ef50aa12@SHWDEOPENPSI011.local/ > Traceback (most recent call last): > File "/stor/work/patchew/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner > response = get_response(request) > File "/stor/work/patchew/venv/lib64/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response > response = self.process_exception_by_middleware(e, request) > File "/stor/work/patchew/venv/lib64/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response > response = wrapped_callback(request, *callback_args, **callback_kwargs) > File "/stor/work/patchew/www/views.py", line 273, in view_series_detail > results=prepare_results(request, s), > File "/stor/work/patchew/www/views.py", line 100, in prepare_results > html = result.render() > File "/stor/work/patchew/api/models.py", line 618, in render > return self.renderer.render_result(self) > File "/stor/work/patchew/mods/git.py", line 191, in render_result > if 'url' in result.data: > TypeError: argument of type 'NoneType' is not iterable _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel
© 2016 - 2025 Red Hat, Inc.