to make bugs private, it must be placed in groups. Name of groups
is not possible fetch via xmlrpc query against bugzilla server.
That means, that everyone must "magically" know the name of group.
And things can go even worst. E.g. if you want to place bug in group
Red Hat Development (internal), it won't be work like that
reporter-bugzilla -g "Red Hat Development (internal)"
because it's not the name of group. Digging into
bugzilla.redhat.com/<some-bug-id> I found
<input type="hidden" name="defined_groups" value="devel">
<input type="checkbox" value="devel" name="groups" id="group_12">
<label for="group_12">Red Hat Development (internal)</label>
<input type="hidden" name="defined_groups" value="redhat">
<input type="checkbox" value="redhat" name="groups" id="group_161">
<label for="group_161">Red Hat Employee (internal)</label>
that means, corrent name for 'Red Hat Development (internal)' is 'devel',
and corrent name for 'Red Hat Employee (internal)' is 'redhat' - tough cookies.
Signed-off-by: Nikola Pajkovsky <[email protected]>
---
doc/reporter-bugzilla.txt | 5 +++-
src/plugins/reporter-bugzilla.c | 6 +++--
src/plugins/rhbz.c | 57 ++++++++++++++++++++++++++++++++-------
src/plugins/rhbz.h | 2 +-
4 files changed, 57 insertions(+), 13 deletions(-)
diff --git a/doc/reporter-bugzilla.txt b/doc/reporter-bugzilla.txt
index 94216ae..1d6af43 100644
--- a/doc/reporter-bugzilla.txt
+++ b/doc/reporter-bugzilla.txt
@@ -7,7 +7,7 @@ reporter-bugzilla - Reports problem to Bugzilla.
SYNOPSIS
--------
-'reporter-bugzilla' [-vbf] [-c CONFFILE] -d DIR
+'reporter-bugzilla' [-vbf] [-g|--group GROUP-NAME]... [-c CONFFILE] -d DIR
Or:
@@ -85,6 +85,9 @@ OPTIONS
-h::
--duphash::
Search in bugzilla by abrt's DUPHASH and return BUG-ID
+-g::
+--group GROUP-NAME::
+ When creating bug, add bug in given group
SEE ALSO
--------
diff --git a/src/plugins/reporter-bugzilla.c b/src/plugins/reporter-bugzilla.c
index bb59ac7..66758a1 100644
--- a/src/plugins/reporter-bugzilla.c
+++ b/src/plugins/reporter-bugzilla.c
@@ -61,7 +61,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] [-c CONFFILE] -d DIR\n"
+ "& [-vbf] [-g|--group GROUP-NAME]... [-c CONFFILE] -d DIR\n"
"or:\n"
"& [-v] [-c CONFFILE] [-d DIR] -t[ID] FILE...\n"
"\n"
@@ -104,6 +104,7 @@ int main(int argc, char **argv)
};
char *ticket_no = NULL, *abrt_hash = NULL;
+ GList *group = NULL;
/* Keep enum above and order of options below in sync! */
struct options program_options[] = {
OPT__VERBOSE(&g_verbose),
@@ -113,6 +114,7 @@ int main(int argc, char **argv)
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")),
OPT_STRING( 'h', "duphash", &abrt_hash, "DUPHASH", _("Find BUG-ID
according to DUPHASH")),
+ OPT_LIST( 'g', "group", &group , "GROUP-NAME", _("Add new bug
in given groups ")),
OPT_END()
};
unsigned opts = parse_opts(argc, argv, program_options,
program_usage_string);
@@ -340,7 +342,7 @@ int main(int argc, char **argv)
{
/* Create new bug */
log(_("Creating a new bug"));
- int bug_id = rhbz_new_bug(client, problem_data, rhbz.b_release);
+ int bug_id = rhbz_new_bug(client, problem_data, rhbz.b_release,
group);
log(_("Adding attachments to bug %i"), bug_id);
char bug_id_str[sizeof(int)*3 + 2];
diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index 579655b..93febbf 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -596,10 +596,13 @@ char *rhbz_get_backtrace_info(problem_data_t
*problem_data, size_t max_text_size
/* 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)
+ const char *release, GList *group)
{
func_entry();
+ if (group)
+ VERB3 log("# of groups %d", g_list_length(group));
+
const char *package = get_problem_item_content_or_NULL(problem_data,
FILENAME_PACKAGE);
const char *component = get_problem_item_content_or_NULL(problem_data,
@@ -693,14 +696,50 @@ 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,
- "version", version,
- "summary", summary,
- "description", full_dsc,
- "status_whiteboard", status_whiteboard,
- "platform", arch);
+
+ if (!group)
+ {
+ 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,
+ "version", version,
+ "summary", summary,
+ "description", full_dsc,
+ "status_whiteboard", status_whiteboard,
+ "platform", arch);
+ }
+ else
+ {
+ xmlrpc_env env;
+ xmlrpc_env_init(&env);
+
+ xmlrpc_value *xmlrpc_groups = xmlrpc_array_new(&env);
+ if (env.fault_occurred)
+ abrt_xmlrpc_die(&env);
+
+ for (GList *l = group; l; l = l->next)
+ {
+ xmlrpc_value *s = xmlrpc_string_new(&env, (char *) l->data);
+ if (env.fault_occurred)
+ abrt_xmlrpc_die(&env);
+
+ xmlrpc_array_append_item(&env, xmlrpc_groups, s);
+ if (env.fault_occurred)
+ abrt_xmlrpc_die(&env);
+
+ xmlrpc_DECREF(s);
+ }
+
+ result = abrt_xmlrpc_call(ax, "Bug.create",
"({s:s,s:s,s:s,s:s,s:s,s:s,s:s,s:A})",
+ "product", product,
+ "component", component,
+ "version", version,
+ "summary", summary,
+ "description", full_dsc,
+ "status_whiteboard", status_whiteboard,
+ "platform", arch,
+ "groups", xmlrpc_groups);
+ }
free(status_whiteboard);
free(product);
diff --git a/src/plugins/rhbz.h b/src/plugins/rhbz.h
index b3084d3..4687aa7 100644
--- a/src/plugins/rhbz.h
+++ b/src/plugins/rhbz.h
@@ -102,7 +102,7 @@ int rhbz_array_size(xmlrpc_value *xml);
int rhbz_bug_id(xmlrpc_value *xml, size_t ver);
int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
- const char *release);
+ const char *release, GList *group);
int rhbz_attach_files(struct abrt_xmlrpc *ax, const char *bug_id,
problem_data_t *problem_data, int flags);
--
1.7.10.2