| |
@@ -612,9 +612,9 @@
|
| |
_update_fixVersion(updates, existing, issue)
|
| |
|
| |
# Only synchronize assignee for listings that op-in
|
| |
- if 'assignee' in updates:
|
| |
+ if any('assignee' in item for item in updates):
|
| |
log.info(" Looking for new assignee(s)")
|
| |
- _update_assignee(client, existing, issue)
|
| |
+ _update_assignee(client, existing, issue, updates)
|
| |
|
| |
# Only synchronize descriptions for listings that op-in
|
| |
if 'description' in updates:
|
| |
@@ -825,33 +825,53 @@
|
| |
log.warning(' Error updating the fixVersion. %s is an invalid fixVersion.' % issue.fixVersion)
|
| |
|
| |
|
| |
- def _update_assignee(client, existing, issue):
|
| |
+ def _update_assignee(client, existing, issue, updates):
|
| |
"""
|
| |
Helper function update existing JIRA assignee from downstream issue
|
| |
Args:
|
| |
client (jira.client.JIRA): JIRA client
|
| |
existing (jira.resource.Issue): Existing JIRA issue
|
| |
issue (sync2jira.intermediary.Issue): Upstream issue
|
| |
+ updates (list): Downstream updates requested by the user
|
| |
Returns:
|
| |
Nothing
|
| |
"""
|
| |
- # Update the assignee
|
| |
+ # First check if overwrite is set to True
|
| |
+ try:
|
| |
+ # For python 3 >
|
| |
+ overwrite = bool(list(filter(lambda d: "assignee" in d, updates))[0]['assignee']['overwrite'])
|
| |
+ except ValueError:
|
| |
+ # for python 2.7
|
| |
+ overwrite = bool((filter(lambda d: "assignee" in d, updates))[0]['assignee']['overwrite'])
|
| |
+
|
| |
+ # First check if the issue is already assigned to the same person
|
| |
+ update = False
|
| |
if issue.assignee and issue.assignee[0]:
|
| |
- # Check if the issue is already assigned to reduce API calls
|
| |
try:
|
| |
update = issue.assignee[0]['fullname'] != existing.fields.assignee.displayName
|
| |
except AttributeError:
|
| |
update = True
|
| |
+
|
| |
+ if not overwrite:
|
| |
+ # Only assign if the existing JIRA issue doesn't have an assignee
|
| |
+ # And the issue has an assignee
|
| |
+ if not existing.fields.assignee and issue.assignee:
|
| |
+ if issue.assignee[0]:
|
| |
+ # Update the assignee
|
| |
+ assign_user(client, issue, existing)
|
| |
+ log.info(' Updated assignee')
|
| |
+ return
|
| |
+ else:
|
| |
+ # Update the assignee if we have someone to assignee it too
|
| |
if update:
|
| |
- # If we have someone to assign it too
|
| |
assign_user(client, issue, existing)
|
| |
log.info(' Updated assignee')
|
| |
- else:
|
| |
- if existing.fields.assignee:
|
| |
- # Else we should remove all assignees
|
| |
- # Set removeAll flag to true
|
| |
- assign_user(client, issue, existing, remove_all=True)
|
| |
- log.info(' Updated assignee')
|
| |
+ else:
|
| |
+ if existing.fields.assignee:
|
| |
+ # Else we should remove all assignees
|
| |
+ # Set removeAll flag to true
|
| |
+ assign_user(client, issue, existing, remove_all=True)
|
| |
+ log.info(' Updated assignee')
|
| |
|
| |
|
| |
def _update_tags(updates, existing, issue):
|
| |