[patchew-devel] [PATCH v2 1/2] git: Improve info if git URL/repo/tag field missing

  • From: Fam Zheng <famz@xxxxxxxxxx>
  • To: patchew-devel@xxxxxxxxxxxxx
  • Date: Thu, 22 Feb 2018 22:32:22 +0800

Signed-off-by: Fam Zheng <famz@xxxxxxxxxx>
---
 mods/git.py | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/mods/git.py b/mods/git.py
index 431b672..e4cef85 100644
--- a/mods/git.py
+++ b/mods/git.py
@@ -141,19 +141,34 @@ class GitModule(PatchewModule):
                 git_url = message.get_property("git.url")
                 git_repo = message.get_property("git.repo")
                 git_tag = message.get_property("git.tag")
-                message.status_tags.append({
-                    "url": git_url,
-                    "title": format_html("Applied as tag {} in repo {}", 
git_tag, git_repo),
-                    "type": "info",
-                    "char": "G",
+                if git_url:
+                    message.status_tags.append({
+                        "url": git_url,
+                        "title": format_html("Applied as tag {} in repo {}", 
git_tag, git_repo),
+                        "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),
+                            "extra": colorbox_div,
+                            "id": "gitlog"
+                        })
+                else:
+                    message.status_tags.append({
+                        "title": format_html("Patches applied succeeded"),
+                        "type": "info",
+                        "char": "G",
+                        })
+                    message.extra_status.append({
+                        "kind": "good",
+                        "html": format_html('Patches applied successfully 
({})',
+                                            colorbox_a),
+                        "extra": colorbox_div,
+                        "id": "gitlog"
                     })
-                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),
-                    "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:
-- 
2.14.3


Other related posts:

  • » [patchew-devel] [PATCH v2 1/2] git: Improve info if git URL/repo/tag field missing - Fam Zheng