aboutsummaryrefslogtreecommitdiff
path: root/bugzilla_create.py
diff options
context:
space:
mode:
Diffstat (limited to 'bugzilla_create.py')
-rwxr-xr-xbugzilla_create.py49
1 files changed, 37 insertions, 12 deletions
diff --git a/bugzilla_create.py b/bugzilla_create.py
index 07817d0..fe20434 100755
--- a/bugzilla_create.py
+++ b/bugzilla_create.py
@@ -30,9 +30,8 @@ from wmfphablib import epoch_to_datetime
from wmfphablib import ipriority
def create(bugid):
- phab = Phabricator(config.phab_user,
- config.phab_cert,
- config.phab_host)
+ phab = Phabricator(token=config.phab_cert,
+ host=config.phab_host)
phabm = phabmacros('', '', '')
phabm.con = phab
@@ -153,10 +152,12 @@ def create(bugid):
if buginfo['status'] == 'verified':
ptags.append(('verified', 'tags'))
- if buginfo['cf_browser'] not in ['---', "Other"]:
- btag = "Browser_Support_%s" % (buginfo['cf_browser'].replace(' ', '-'),)
- log('Adding browser tag: %s' % (btag,))
- ptags.append((btag, 'tags'))
+ #kspoon: I think this is a custom WM thing... might need to lift it
+ # for any bugzilla customizations linaro has added
+ #if buginfo['cf_browser'] not in ['---', "Other"]:
+ # btag = "Browser_Support_%s" % (buginfo['cf_browser'].replace(' ', '-'),)
+ # log('Adding browser tag: %s' % (btag,))
+ # ptags.append((btag, 'tags'))
if buginfo['target_milestone'] != '---':
log('Creating milestone: %s' % (buginfo['target_milestone'],))
@@ -165,10 +166,25 @@ def create(bugid):
#set defaults to be overridden by sec if needed
buginfo['viewPolicy'] = 'public'
buginfo['editPolicy'] = 'users'
- buginfo['project'] = bzlib.sanitize_project_name(buginfo["product"],
- buginfo["component"])
+ #buginfo['project'] = bzlib.sanitize_project_name(buginfo["product"],
+ # buginfo["component"])
+
+ #kspoon: for linaro, we want to create the product as a container/parent
+ # project, and the components as subprojects of the parent whereas wm just
+ # flattened it.
+ buginfo['parent_project'] = bzlib.sanitize_project_name(buginfo["product"])
+ parent_phid = phabm.get_project_phid(buginfo['parent_project'])
+ if not parent_phid:
+ parent_phid = phabm.ensure_project(buginfo['parent_project'], parent_phid=None, edit='public', view='public')
+
+ buginfo['bugzilla_id'] = "bugzilla-%s" % buginfo['id']
+
+ print "parent_phid set to %s" % parent_phid
+
+ buginfo['project'] = bzlib.sanitize_project_name(buginfo["component"])
vlog(buginfo['project'])
ptags.append((buginfo['project'], None))
+ ptags.append((buginfo['parent_project'], None))
title = buginfo['summary']
@@ -195,7 +211,7 @@ def create(bugid):
'creation_time': buginfo['creation_time']}
created = epoch_to_datetime(description['creation_time'])
- desc_block = "**Author:** `%s`\n\n**Description:**\n%s\n" % (description['author'],
+ desc_block = "**Creator:** `%s`\n\n**Description:**\n%s\n" % (description['creator'],
description['text'])
# https://phabricator.wikimedia.org/T694
@@ -254,7 +270,7 @@ def create(bugid):
phids = []
for p in ptags:
edit, view = project_security_settings(p[0])
- phid = phabm.ensure_project(p[0], edit=edit, view=view)
+ phid = phabm.ensure_project(p[0], parent_phid=parent_phid, edit=edit, view=view)
phids.append(phid)
if p[1] is not None:
vlog("setting project %s icon to %s" % (p[0], p[1]))
@@ -273,6 +289,15 @@ def create(bugid):
# viewPolicy = buginfo['viewPolicy'],
# editPolicy = buginfo['editPolicy'],
vlog("Ticket Info: %s" % (desc_block,))
+ #kspoon: see if ticket already exists by checking title... not a great
+ # idea. Should search for bugzilla-<id> tag instead
+ print "looking up tickets..."
+ tickets = phab.maniphest.search(constraints={'query':'"%s"' % buginfo['summary']}, queryKey='all', order='newest')
+
+ # if
+ if len( tickets['data'] ) > 0:
+ log("Task exists: T%s (%s)" % (tickets['data'][0]['id'], tickets['data'][0]['phid']))
+ return True
ticket = phab.maniphest.createtask(title=buginfo['summary'],
description=full_description,
projectPHIDs=phids,
@@ -295,7 +320,7 @@ def create(bugid):
for c in clean_com:
fmt_comment = {}
created = epoch_to_datetime(c['creation_time'])
- comment_header = "**%s** wrote:\n\n" % (c['author'],)
+ comment_header = "**%s** wrote:\n\n" % (c['creator'],)
comment_body = c['text']
attachments = ''
if 'attachment' in c: