---
mods/git.py | 62 +++++++++++++++++++++++++++++------------------------
1 file changed, 34 insertions(+), 28 deletions(-)
diff --git a/mods/git.py b/mods/git.py
index 1f22f2e..3032e39 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'] = 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
© 2016 - 2025 Red Hat, Inc.