Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Commit

Permalink
TOOLS-295: mo's Bot Bot Jira commenting borks on non-ascii in commite…
Browse files Browse the repository at this point in the history
…rs name
  • Loading branch information
trentm committed Sep 13, 2013
1 parent 7b98687 commit 8393d23
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tools/jira-post-fetch-hook
Expand Up @@ -33,7 +33,7 @@ warnings.simplefilter("ignore")
# Note: The space btwn URL and closing ']' is intentional so that gmail
# doesn't include the ']*' as part of the link (breaking it). The extra
# space doesn't confuse Jira, so all good.
TEMPLATE = """
TEMPLATE = u"""
{panel:borderColor=#ccc|borderStyle=solid|bgColor=#d3e1fe}
*[%(repo)s commit %(sha)s|%(moUrl)s/%(repo)s/commit/%(sha)s ]* *(**[branch %(branch)s|%(moUrl)s/%(repo)s/commits/%(branch)s ]**, by %(author)s)*
Expand All @@ -59,7 +59,9 @@ cfg = None # object set in `main`.
def printError(errmsg):
lines = [
"* * *",
"* %s %s" % (sys.executable, ' '.join(sys.argv)),
"* cd %s && MOLYBDENUM_CONFIG=%s %s %s" % (
os.getcwd(), os.environ["MOLYBDENUM_CONFIG"],
sys.executable, ' '.join(sys.argv)),
"*"
]
lines += ["* "+s for s in errmsg.splitlines(False)]
Expand Down Expand Up @@ -192,13 +194,17 @@ def main(argv=sys.argv):
"moUrl": jiraCfg["moUrl"],
"repo": repo,
"sha": sha,
"author": commitInfo["author"],
"message": jiraCommentEscape(commitInfo["message"].rstrip()),
"author": commitInfo["author"].decode('utf8'),
"message": jiraCommentEscape(commitInfo["message"].rstrip()).decode('utf8'),
"branch": branch
}
for jira in genJiraIssues(commitInfo, jiraCfg):
print "\t> %s (commit %s, branch %s)" % (jira, sha, branch)
comment = TEMPLATE % data
# Python: demerit. Basically can't get non-ascii through
# the xmlrpclib.py 'dumps' function. I'm giving up on
# trying to get that to work... with Python 2.7 anyway.
comment = comment.encode('ascii', 'replace')
if not cfg["dryRun"]:
authToken = getAuthToken(server, jiraCfg)
server.jira1.addComment(authToken, jira, comment)
Expand Down

0 comments on commit 8393d23

Please sign in to comment.