libreport/0007-bugzilla-put-VARIANT_ID-to-Whiteboard.patch
Matej Habrnal 90e88e5a1d bugzilla: put VARIANT_ID= to Whiteboard
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
2015-09-15 11:02:40 +02:00

80 lines
2.9 KiB
Diff

From fdf8665e241190d1a7406ae2958e88d17f9b372b Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Tue, 1 Sep 2015 14:56:21 +0200
Subject: [PATCH] bugzilla: put VARIANT_ID= to Whiteboard
Parse /etc/os-release ('os-info' element), read VARIANT_ID and put its
value to Whiteboard of the newly created bug.
This commit allows users to search for ";VARIANT_ID=$ID;".
Related to abrt/abrt#995
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
src/plugins/rhbz.c | 34 +++++++++++++++++++++++++++++++---
1 file changed, 31 insertions(+), 3 deletions(-)
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index a376c13..c4af091 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -520,7 +520,35 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
char *summary = shorten_string_to_length(bzsummary, MAX_SUMMARY_LENGTH);
- char *status_whiteboard = xasprintf("abrt_hash:%s", duphash);
+ struct strbuf *status_whiteboard = strbuf_new();
+ strbuf_append_strf(status_whiteboard, "abrt_hash:%s;", duphash);
+
+ { /* Add fields from /etc/os-release to Whiteboard for simple metrics. */
+ map_string_t *osinfo = new_map_string();
+ problem_data_get_osinfo(problem_data, osinfo);
+
+ /* This is the highest abstraction level I am willing to introduce now.
+ *
+ * The lines below can be either reduced to the body of the for loop
+ * or the opts variable can be dynamically initialized
+ * or you can simply add an another /etc/os-release option name
+ * (e.g. BUILD_ID).
+ */
+ const char *const opts[] = { "VARIANT_ID", NULL };
+ for (const char *const *iter = opts; *iter != NULL; ++iter)
+ {
+ const char *v = get_map_string_item_or_NULL(osinfo, *iter);
+ if (v != NULL)
+ {
+ /* semi-colon (;) is the delimiter because /etc/os-release *_ID
+ * options does not permit the ';' character in values
+ */
+ strbuf_append_strf(status_whiteboard, "%s=%s;", *iter, v);
+ }
+ }
+
+ free_map_string(osinfo);
+ }
xmlrpc_env env;
xmlrpc_env_init(&env);
@@ -532,7 +560,7 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
abrt_xmlrpc_params_add_string(&env, params, "version", version);
abrt_xmlrpc_params_add_string(&env, params, "summary", summary);
abrt_xmlrpc_params_add_string(&env, params, "description", bzcomment);
- abrt_xmlrpc_params_add_string(&env, params, "status_whiteboard", status_whiteboard);
+ abrt_xmlrpc_params_add_string(&env, params, "status_whiteboard", status_whiteboard->buf);
if(arch)
abrt_xmlrpc_params_add_string(&env, params, "platform", arch);
@@ -562,7 +590,7 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
xmlrpc_DECREF(params);
xmlrpc_env_clean(&env);
- free(status_whiteboard);
+ strbuf_free(status_whiteboard);
free(summary);
if (!result)
--
2.5.0