Skip to content

Commit

Permalink
Fixes #8550: rudder-dev wip should add a comment on the bugtracker
Browse files Browse the repository at this point in the history
  • Loading branch information
peckpeck committed Jun 16, 2016
1 parent 529c2cf commit 489aac8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
44 changes: 43 additions & 1 deletion scripts/rudder-dev/redmine.py
Expand Up @@ -151,12 +151,54 @@ def branch_name(self):
id = 'i' + str(self.id)
else:
id = str(self.id)
if info['private']:
if self['private']:
branch_name = Config.TRACKER_NAME_MAPPING[self['type']] + "_" + id + "/_"
else:
branch_name = Config.TRACKER_NAME_MAPPING[self['type']] + "_" + id + "/" + branchified_name
return branch_name

# Change ticket state and comment it
def update(self, user_id=None, pr_url=None, message=None, status=None):
# Create note content
note = None
if pr_url is not None:
note = "PR " + pr_url
if message is not None:
if note is None:
note = message
else:
note += "\n" + message

ticket_info = { 'issue': {} }
if can_modify_issues(self['project_id']):
# fill ticket data with developer available content
if status is not None:
ticket_info['issue']['status_id'] = status
if user_id is not None:
ticket_info['issue']['assigned_to_id'] = user_id
if note is not None:
ticket_info['issue']['notes'] = note
if pr_url is not None:
ticket_info['issue']['custom_fields'] = [ { 'id': Config.CUSTOM_FIELD_PR, 'value': pr_url } ]

else:
# just append the note to ticket, if any
if note is None:
return
else:
ticket_info['issue']['notes'] = note

# call the api
url = Config.REDMINE_API_URL + "/issues/" + str(self.id) + ".json"
ticket_json = json.dumps(ticket_info)
ret = requests.put(url, headers = {'X-Redmine-API-Key': Config.REDMINE_TOKEN, 'Content-Type': 'application/json' }, data=ticket_json )
if ret.status_code != 200:
logfail("Ticket Update error: " + ret.reason)
print(ret.text)
if not Config.force:
exit(3)


def issue_from_branch(branch):
"""Create issue object from given branch"""
match = re.match(r'[A-Za-z]+_(i?\d+)/.*', branch)
Expand Down
11 changes: 6 additions & 5 deletions scripts/rudder-dev/rudder-dev-src
Expand Up @@ -413,6 +413,7 @@ def update_ticket_version(info, version):


# Change ticket state to technical review
# Deprecated, use Issue.update()
def ticket_to_TR(info, user_id=None, pr_url=None, message=None):
# Create note content
note = None
Expand Down Expand Up @@ -1117,16 +1118,16 @@ def subtask(next_version, new_title, base=None, bug=False):
# commit, push
def wip():
# must be on a working branch
match = re.match(r'[A-Za-z]+_(i?)(\d+)/.*', current_branch)
if not match:
logfail("***** ERROR: This is not a ticket branch: " + branch)
exit(4)
issue = issue_from_branch(current_branch)
commit_push(current_branch, "Work in progress")
url = "https://github.com/{user}/{repo}/commit/{commit}"
user = get_github_user()
repo = remote_repo()
commit = shell("git rev-parse HEAD", keep_output=True).strip()
print("You can find the commit here: " + url.format(user=user, repo=repo, commit=commit))
# add a wip comment on the issue to find it later
commit_url = url.format(user=user, repo=repo, commit=commit)
issue.update(message="Work in progess here: " + commit_url)
print("You can find the commit here: " + commit_url)


# Commit, push, create pull-request, update ticket
Expand Down

0 comments on commit 489aac8

Please sign in to comment.