Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/lib/make_descr.c | 2 +
src/plugins/rhbz.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++---
src/plugins/rhbz.h | 11 +++++
3 files changed, 108 insertions(+), 6 deletions(-)
diff --git a/src/lib/make_descr.c b/src/lib/make_descr.c
index 68133a2..c66da05 100644
--- a/src/lib/make_descr.c
+++ b/src/lib/make_descr.c
@@ -263,6 +263,7 @@ static const char *const blacklisted_items[] = {
NULL
};
+#ifdef UNUSED
char* make_description_bz(problem_data_t *problem_data, unsigned max_text_size)
{
return make_description(
@@ -272,6 +273,7 @@ char* make_description_bz(problem_data_t *problem_data, unsigned
max_text_size)
MAKEDESC_SHOW_FILES | MAKEDESC_SHOW_MULTILINE
);
}
+#endif
char* make_description_logger(problem_data_t *problem_data, unsigned max_text_size)
{
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index a3aa2ef..bba5800 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -381,10 +381,50 @@ struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id)
return bz;
}
+/* helper function for skipping trailing new lines strings passed to *printf()
+ *
+ * @param text some string, it must not be NULL
+ * @return len of string minus number of trainling new lines
+ */
+static int strlen_minus_trailing_new_lines(const char* text)
+{
+ int len = strlen(text);
+
+ while (text[len-1] == '\n' && len > 1 )
+ --len;
+
+ return len;
+}
+
/* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
const char *release)
{
+ /* Items we don't want to include to bz */
+ static const char *const additional_info_blacklisted_items[] = {
+ CD_DUMPDIR ,
+ FILENAME_ANALYZER ,
+ FILENAME_COREDUMP ,
+ FILENAME_HOSTNAME ,
+ FILENAME_DUPHASH ,
+ FILENAME_UUID ,
+ FILENAME_COUNT ,
+ FILENAME_TAINTED_SHORT,
+ FILENAME_ARCHITECTURE,
+ FILENAME_PACKAGE,
+ FILENAME_OS_RELEASE,
+ FILENAME_COMPONENT,
+ FILENAME_REASON,
+ FILENAME_COMMENT,
+ FILENAME_PACKAGE,
+ /* plugin specific files */
+ RHBZ_FILENAME_HOW_REPRODUCIBLE,
+ RHBZ_FILENAME_STEPS_TO_REPRODUCE,
+ RHBZ_FILENAME_ACTUAL_RESULTS,
+ RHBZ_FILENAME_EXPECTED_RESULTS,
+ NULL
+ };
+
const char *package = get_problem_item_content_or_NULL(problem_data,
FILENAME_PACKAGE);
const char *component = get_problem_item_content_or_NULL(problem_data,
@@ -436,16 +476,64 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t
*problem_data,
strbuf_append_strf(buf_summary, ": TAINTED %s", tainted_short);
}
}
+
char *status_whiteboard = xasprintf("abrt_hash:%s", duphash);
- char *bz_dsc;
+ /* TODO :
+ * move generation of the full description to a solo function, if we need to
+ * show a preview */
+ const char *comment = get_problem_item_content_or_NULL(problem_data,
+ FILENAME_COMMENT);
+
+ const char *how_reproducible = get_problem_item_content_or_NULL(problem_data,
+
RHBZ_FILENAME_HOW_REPRODUCIBLE);
+
+ const char *steps_to_reproduce = get_problem_item_content_or_NULL(problem_data,
+
RHBZ_FILENAME_STEPS_TO_REPRODUCE);
+
+ const char *actual_results = get_problem_item_content_or_NULL(problem_data,
+
RHBZ_FILENAME_ACTUAL_RESULTS);
+
+ const char *expected_results = get_problem_item_content_or_NULL(problem_data,
+
RHBZ_FILENAME_EXPECTED_RESULTS);
+
+ char *additional_info;
if (analyzer && !strcmp(analyzer, "Kerneloops"))
- bz_dsc = make_description_koops(problem_data, CD_TEXT_ATT_SIZE_BZ);
+ additional_info = make_description_koops(problem_data, CD_TEXT_ATT_SIZE_BZ);
else
- bz_dsc = make_description_bz(problem_data, CD_TEXT_ATT_SIZE_BZ);
-
- char *full_dsc = xasprintf("libreport version: "VERSION"\n%s",
bz_dsc);
- free(bz_dsc);
+ additional_info = make_description(
+ problem_data,
+ (char**)additional_info_blacklisted_items,
+ CD_TEXT_ATT_SIZE_BZ,
+ MAKEDESC_SHOW_FILES | MAKEDESC_SHOW_MULTILINE
+ );
+
+ /* if item is missing used appropriate informative text */
+ comment = comment ? comment :
RHBZ_ITEM_NOT_PROVIDED_BY_USER;
+ how_reproducible = how_reproducible ? how_reproducible :
RHBZ_ITEM_NOT_PROVIDED_BY_USER;
+ steps_to_reproduce = steps_to_reproduce ? steps_to_reproduce :
RHBZ_ITEM_NOT_PROVIDED_BY_USER;
+ actual_results = actual_results ? actual_results :
RHBZ_ITEM_NOT_PROVIDED_BY_USER;
+ expected_results = expected_results ? expected_results :
RHBZ_ITEM_NOT_PROVIDED_BY_USER;
+
+ /* full bug description according to default template */
+ char *full_dsc = xasprintf(
+ "Description of problem:\n%.*s\n\n"
+ "Version-Release number of selected component (if
applicable):\n%.*s\n\n"
+ "How reproducible:\n%.*s\n\n"
+ "Steps to Reproduce:\n%.*s\n\n"
+ "Actual results:\n%.*s\n\n"
+ "Expected results:\n%.*s\n\n"
+ "Additional info:\nlibreport version: "VERSION"\n%.*s\n"
+ /* Description of problem */ , strlen_minus_trailing_new_lines(comment),
comment
+ /* Version-Release number */ , strlen_minus_trailing_new_lines(package),
package
+ /* How reproducible */ ,
strlen_minus_trailing_new_lines(how_reproducible), how_reproducible
+ /* Steps to reproduce */ ,
strlen_minus_trailing_new_lines(steps_to_reproduce), steps_to_reproduce
+ /* Actual results */ ,
strlen_minus_trailing_new_lines(actual_results), actual_results
+ /* Expected results */ ,
strlen_minus_trailing_new_lines(expected_results), expected_results
+ /* Additional info */ ,
strlen_minus_trailing_new_lines(additional_info), additional_info
+ );
+
+ free(additional_info);
char *product = NULL;
char *version = NULL;
@@ -453,6 +541,7 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t
*problem_data,
xmlrpc_value* result = NULL;
char *summary = strbuf_free_nobuf(buf_summary);
+
result = abrt_xmlrpc_call(ax, "Bug.create",
"({s:s,s:s,s:s,s:s,s:s,s:s,s:s})",
"product", product,
"component", component,
diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h
index c9023e9..a00874a 100644
--- a/src/plugins/rhbz.h
+++ b/src/plugins/rhbz.h
@@ -30,6 +30,17 @@
extern "C" {
#endif
+/* reporter-bugzilla plugin specific additional file names
+ */
+#define RHBZ_FILENAME_HOW_REPRODUCIBLE "how_reproducible"
+#define RHBZ_FILENAME_STEPS_TO_REPRODUCE "steps_to_reproduce"
+#define RHBZ_FILENAME_ACTUAL_RESULTS "actual_results"
+#define RHBZ_FILENAME_EXPECTED_RESULTS "expected_results"
+
+/* reporter-bugzilla substitutional texts for missing problem items
+ */
+#define RHBZ_ITEM_NOT_PROVIDED_BY_USER "<this item is not provided by
user>"
+
enum {
RHBZ_MANDATORY_MEMB = (1 << 0),
RHBZ_READ_STR = (1 << 1),
--
1.7.7.6