The new flag "reporter-bugzilla -A FILE" can be used to specify a different
comment format file. We supply example file (bugzilla_formatdup.conf).
abrt package will use that file.

-- 
vda

diff -x '*.po' -d -urpN libreport.7/libreport.spec.in 
libreport.8/libreport.spec.in
--- libreport.7/libreport.spec.in       2013-01-10 14:18:05.000000000 +0100
+++ libreport.8/libreport.spec.in       2013-01-16 14:54:48.960506138 +0100
@@ -391,6 +391,7 @@ gtk-update-icon-cache %{_datadir}/icons/
 %defattr(-,root,root,-)
 %config(noreplace) %{_sysconfdir}/libreport/plugins/bugzilla.conf
 %config(noreplace) %{_sysconfdir}/libreport/plugins/bugzilla_format.conf
+%config(noreplace) %{_sysconfdir}/libreport/plugins/bugzilla_formatdup.conf
 %config(noreplace) 
%{_sysconfdir}/libreport/plugins/bugzilla_format_libreport.conf
 %config(noreplace) %{_sysconfdir}/libreport/plugins/bugzilla_format_kernel.conf
 %{_sysconfdir}/libreport/events/report_Bugzilla.xml
diff -x '*.po' -d -urpN libreport.7/src/plugins/bugzilla_formatdup.conf 
libreport.8/src/plugins/bugzilla_formatdup.conf
--- libreport.7/src/plugins/bugzilla_formatdup.conf     1970-01-01 
01:00:00.000000000 +0100
+++ libreport.8/src/plugins/bugzilla_formatdup.conf     2013-01-16 
14:54:34.667524306 +0100
@@ -0,0 +1,54 @@
+# Lines starting with # are ignored.
+# Lines can be continued on the next line using trailing backslash.
+#
+# Format:
+# %summary:: summary format
+# section:: element1[,element2]...
+# The literal text line to be added to Bugzilla comment. Can be empty.
+# (IOW: empty lines are NOT ignored!)
+#
+# Summary format is a line of text, where %element% is replaced by
+# text element's content, and [[...%element%...]] block is used only if
+# %element% exists. [[...]] blocks can nest.
+#
+# Sections can be:
+# - %summary: bug summary format string.
+# - %attach: a list of elements to attach.
+# - text, double colon (::) and the list of comma-separated elements.
+#
+# Elements can be:
+# - problem directory element names, which get formatted as
+#   <element_name>: <contents>
+#   or
+#   <element_name>:
+#   :<contents>
+#   :<contents>
+#   :<contents>
+# - problem directory element names prefixed by "%bare_",
+#   which is formatted as-is, without "<element_name>:" and colons
+# - %oneline, %multiline, %text wildcards, which select all corresponding
+#   elements for output or attachment
+# - %binary wildcard, valid only for %attach section, instructs to attach
+#   binary elements
+# - problem directory element names prefixed by "-",
+#   which excludes given element from all wildcards
+#
+#   Nonexistent elements are silently ignored.
+#   If none of elements exists, the section will not be created.
+
+%summary:: [abrt] %package%[[: %crash_function%]][[: %reason%]][[: TAINTED 
%tainted_short%]]
+
+Description of problem:: %bare_comment
+
+Version-Release number of selected component:: %bare_package
+
+# var_log_messages has too much variance (time/date),
+# we exclude it from message so that dup message elimination has more chances 
to work
+Additional info:: \
+       -pkg_arch,-pkg_epoch,-pkg_name,-pkg_release,-pkg_version,\
+               -component,-architecture,\
+       -analyzer,-count,-duphash,-uuid,-abrt_version,\
+       -username,-hostname,-os_release,\
+       -time,-pid,-pwd,\
+       -var_log_messages,\
+       %oneline
diff -x '*.po' -d -urpN libreport.7/src/plugins/Makefile.am 
libreport.8/src/plugins/Makefile.am
--- libreport.7/src/plugins/Makefile.am 2013-01-10 14:18:05.000000000 +0100
+++ libreport.8/src/plugins/Makefile.am 2013-01-16 14:55:27.372457362 +0100
@@ -25,6 +25,7 @@ reporters_plugin_conf =
 if BUILD_BUGZILLA
 reporters_plugin_conf += bugzilla.conf \
     bugzilla_format.conf \
+    bugzilla_formatdup.conf \
     bugzilla_format_libreport.conf \
     bugzilla_format_kernel.conf

diff -x '*.po' -d -urpN libreport.7/src/plugins/reporter-bugzilla.c 
libreport.8/src/plugins/reporter-bugzilla.c
--- libreport.7/src/plugins/reporter-bugzilla.c 2013-01-15 12:23:21.000000000 
+0100
+++ libreport.8/src/plugins/reporter-bugzilla.c 2013-01-16 14:47:48.722044298 
+0100
@@ -794,7 +794,7 @@ int main(int argc, char **argv)

     /* Can't keep these strings/structs static: _() doesn't support that */
     const char *program_usage_string = _(
-        "\n& [-vbf] [-g GROUP-NAME]... [-c CONFFILE]... [-F FMTFILE] -d DIR"
+        "\n& [-vbf] [-g GROUP-NAME]... [-c CONFFILE]... [-F FMTFILE] [-A 
FMTFILE2] -d DIR"
         "\nor:"
         "\n& [-v] [-c CONFFILE]... [-d DIR] -t[ID] FILE..."
         "\nor:"
@@ -833,24 +833,26 @@ int main(int argc, char **argv)
         "\nRecognized boolean parameter (VALUE should be 1/0, yes/no): 
SSLVerify."
         "\nParameters can be overridden via $Bugzilla_PARAM environment 
variables."
         "\n"
-        "\nFMTFILE defaults to "CONF_DIR"/plugins/bugzilla_format.conf"
+        "\nFMTFILE and FMTFILE2 default to 
"CONF_DIR"/plugins/bugzilla_format.conf"
     );
     enum {
         OPT_v = 1 << 0,
         OPT_d = 1 << 1,
         OPT_c = 1 << 2,
         OPT_F = 1 << 3,
-        OPT_t = 1 << 4,
-        OPT_b = 1 << 5,
-        OPT_f = 1 << 6,
-        OPT_w = 1 << 7,
-        OPT_h = 1 << 8,
-        OPT_g = 1 << 9,
-        OPT_D = 1 << 10,
+        OPT_A = 1 << 4,
+        OPT_t = 1 << 5,
+        OPT_b = 1 << 6,
+        OPT_f = 1 << 7,
+        OPT_w = 1 << 8,
+        OPT_h = 1 << 9,
+        OPT_g = 1 << 10,
+        OPT_D = 1 << 11,
     };
     const char *dump_dir_name = ".";
     GList *conf_file = NULL;
     const char *fmt_file = CONF_DIR"/plugins/bugzilla_format.conf";
+    const char *fmt_file2 = fmt_file;
     char *abrt_hash = NULL;
     char *ticket_no = NULL;
     char *debug_str = NULL;
@@ -860,7 +862,8 @@ int main(int argc, char **argv)
         OPT__VERBOSE(&g_verbose),
         OPT_STRING(   'd', NULL, &dump_dir_name , "DIR"    , _("Problem 
directory")),
         OPT_LIST(     'c', NULL, &conf_file     , "FILE"   , _("Configuration 
file (may be given many times)")),
-        OPT_STRING(   'F', NULL, &fmt_file      , "FILE"   , _("Formatting 
file")),
+        OPT_STRING(   'F', NULL, &fmt_file      , "FILE"   , _("Formatting 
file for initial comment")),
+        OPT_STRING(   'A', NULL, &fmt_file2     , "FILE"   , _("Formatting 
file for duplicates")),
         OPT_OPTSTRING('t', "ticket", &ticket_no , "ID"     , _("Attach FILEs 
[to bug with this ID]")),
         OPT_BOOL(     'b', NULL, NULL,                       _("When creating 
bug, attach binary files too")),
         OPT_BOOL(     'f', NULL, NULL,                       _("Force 
reporting even if this problem is already reported")),
@@ -1215,65 +1218,43 @@ int main(int argc, char **argv)
             rhbz_mail_to_cc(client, bz->bi_id, rhbz.b_login, 
RHBZ_NOMAIL_NOTIFY);
         }

-        /* Add comment */
+        /* Add comment and bt */
         const char *comment = problem_data_get_content_or_NULL(problem_data, 
FILENAME_COMMENT);
         if (comment && comment[0])
         {
-            const char *package = 
problem_data_get_content_or_NULL(problem_data, FILENAME_PACKAGE);
-            const char *arch    = 
problem_data_get_content_or_NULL(problem_data, FILENAME_ARCHITECTURE);
-            const char *rating_str = 
problem_data_get_content_or_NULL(problem_data, FILENAME_RATING);
-
-            struct strbuf *full_desc = strbuf_new();
-            strbuf_append_strf(full_desc, "%s\n\n", comment);
-
-            /* python doesn't have rating file */
-            if (rating_str)
-                strbuf_append_strf(full_desc, "%s: %s\n", FILENAME_RATING, 
rating_str);
-            strbuf_append_strf(full_desc, "Package: %s\n", package);
-            /* attach the architecture only if it's different from the initial 
report */
-            if ((strcmp(bz->bi_platform, "All") != 0) &&
-                (strcmp(bz->bi_platform, "Unspecified") != 0) &&
-                (strcmp(bz->bi_platform, arch) !=0))
-                strbuf_append_strf(full_desc, "Architecture: %s\n", arch);
-            else
-            {
-                VERB3 log("not adding the arch: %s because rep_plat is %s", 
arch, bz->bi_platform);
-            }
-            strbuf_append_strf(full_desc, "OS Release: %s\n", 
rhbz.b_os_release);
-
-            /* unused code, enable it when gui/cli will be ready
-            int is_priv = is_private && string_to_bool(is_private);
-            const char *is_private = 
problem_data_get_content_or_NULL(problem_data,
-                                                                      
"is_private");
-            */
+            GList *comment_fmt_spec = load_bzrep_conf_file(fmt_file2);
+            struct strbuf *bzcomment_buf = strbuf_new();
+            generate_bz_comment(bzcomment_buf, problem_data, comment_fmt_spec);
+            char *bzcomment = strbuf_free_nobuf(bzcomment_buf);
+//TODO: free_comment_fmt_spec(comment_fmt_spec);

-            int dup_comment = is_comment_dup(bz->bi_comments, full_desc->buf);
+            int dup_comment = is_comment_dup(bz->bi_comments, bzcomment);
             if (!dup_comment)
             {
                 log(_("Adding new comment to bug %d"), bz->bi_id);
-                rhbz_add_comment(client, bz->bi_id, full_desc->buf, 0);
+                rhbz_add_comment(client, bz->bi_id, bzcomment, 0);
+                free(bzcomment);
+
+                const char *bt = 
problem_data_get_content_or_NULL(problem_data, FILENAME_BACKTRACE);
+                unsigned rating = 0;
+                const char *rating_str = 
problem_data_get_content_or_NULL(problem_data, FILENAME_RATING);
+                /* python doesn't have rating file */
+                if (rating_str)
+                    rating = xatou(rating_str);
+                if (bt && rating > bz->bi_best_bt_rating)
+                {
+                    char bug_id_str[sizeof(int)*3 + 2];
+                    sprintf(bug_id_str, "%i", bz->bi_id);
+                    log(_("Attaching better backtrace"));
+                    rhbz_attach_blob(client, FILENAME_BACKTRACE, bug_id_str, 
bt, strlen(bt),
+                                     RHBZ_NOMAIL_NOTIFY);
+                }
             }
             else
             {
+                free(bzcomment);
                 log(_("Found the same comment in the bug history, not adding a 
new one"));
             }
-            strbuf_free(full_desc);
-
-            unsigned rating = 0;
-            /* python doesn't have rating file */
-            if (rating_str)
-                rating = xatou(rating_str);
-            if (!dup_comment && (rating > bz->bi_best_bt_rating))
-            {
-                char bug_id_str[sizeof(int)*3 + 2];
-                snprintf(bug_id_str, sizeof(bug_id_str), "%i", bz->bi_id);
-
-                const char *bt = problem_data_get_content_or_NULL(problem_data,
-                                                                   
FILENAME_BACKTRACE);
-                log(_("Attaching better backtrace"));
-                rhbz_attach_blob(client, FILENAME_BACKTRACE, bug_id_str, bt, 
strlen(bt),
-                                 RHBZ_NOMAIL_NOTIFY);
-            }
         }
     }

Reply via email to