[Patchew-devel] [PATCH] git: remove useless result.log_url check

Paolo Bonzini posted 1 patch 5 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180521144458.32564-1-pbonzini@redhat.com
mods/git.py | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
[Patchew-devel] [PATCH] git: remove useless result.log_url check
Posted by Paolo Bonzini 5 years, 11 months ago
result.log_url is not None if and only if result.is_completed() is
false, so it is not necessary to check twice for it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 mods/git.py | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/mods/git.py b/mods/git.py
index 48711db..7d8afbb 100644
--- a/mods/git.py
+++ b/mods/git.py
@@ -181,25 +181,24 @@ class GitModule(PatchewModule):
         if not result.is_completed():
             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.is_failure():
-                return format_html('Failed in applying to current master ({})', colorbox_a)
+        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.is_failure():
+            return format_html('Failed in applying to current master ({})', colorbox_a)
+        else:
+            if 'url' in result.data:
+                s = format_html('<a href="{}">tree</a>, {}', result.data['url'], 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
+                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):
-- 
2.17.0

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel
Re: [Patchew-devel] [PATCH] git: remove useless result.log_url check
Posted by Fam Zheng 5 years, 11 months ago
On Mon, 05/21 16:44, Paolo Bonzini wrote:
> result.log_url is not None if and only if result.is_completed() is
> false, so it is not necessary to check twice for it.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Fam Zheng <famz@redhat.com>

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel