Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion jiraclient/jiraclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def parse_args(self):
- Create an issue with a specified Component and Fix Version
and assign it to myself:
jiraclient.py -u 'username' -p 'jirapassword' -A 'username' -P INFOSYS -Q major -F 10000 -C 10003 -T epic -S 'Investigate Platform IFS'

- Unassign an existing issue:
jiraclient.py -u 'username' -p 'jirapassword' -i INFO-1000 -A Unassigned
"""
optParser = OptionParser(usage)
optParser.add_option(
Expand Down Expand Up @@ -301,7 +304,7 @@ def parse_args(self):
"-A","--assignee",
action="store",
dest="assignee",
help="Jira assignee",
help="Jira assignee (specify Unassigned to unassign the issue)",
default=None,
)
optParser.add_option(
Expand Down Expand Up @@ -716,6 +719,17 @@ def add_comment(self,issueID,comment):
result = self.call_api('post',uri,payload=comment)
return result

def is_assignee_unassigned(self, issue):
return issue.has_key('assignee') and issue['assignee'].has_key('name') and issue['assignee']['name'] == 'Unassigned'

def fix_assignee(self, issue):
if self.is_assignee_unassigned(issue):
new_issue = issue.copy()
new_issue['assignee']['name'] = None
return new_issue
else:
return issue

def clean_issue(self,issue):
# We have an Issue with a number of required default values
# that are often empty. Remove the empty ones so as to not
Expand All @@ -730,6 +744,7 @@ def clean_issue(self,issue):
if v == {"key":None}: issue.pop(k)
if v == {"originalEstimate":None}: issue.pop(k)
if v == [{"id":None}]: issue.pop(k)
issue = self.fix_assignee(issue)
self.logger.debug("cleaned issue: %s" % issue)
return issue

Expand Down