Commit fd45e919 authored by Francois Marier's avatar Francois Marier

gerrit merge hook: send emails to Launchpad

This is now live and it works fine.
parent fcc328c3
......@@ -24,8 +24,8 @@ import smtplib
import subprocess
import sys
FROM_ADDRESS = 'gerrit@reviews.mahara.org'
TO_ADDRESS = 'francois@catalyst.net.nz'
FROM_ADDRESS = 'dev@mahara.org'
TO_ADDRESS_SUFFIX = '@bugs.launchpad.net'
BASE_DIR = '/home/gerrit/mahara_reviews'
def email_tracker(change_url, project, branch, submitter, commit):
......@@ -41,22 +41,26 @@ def email_tracker(change_url, project, branch, submitter, commit):
for token in tokens:
if re.match('^\d+$', token) and (token not in bugs):
bugs.append(token)
send_bug_mail(token, change_url, project, commit, submitter, branch, git_log)
def send_bug_mail(bug_number, change_url, project, commit, submitter, branch, git_log):
to_address = bug_number + TO_ADDRESS_SUFFIX
gitorious_url = 'http://gitorious.org/mahara/%s/commit/%s' % (project, commit)
body = '''Reviewed: %s
Committed: %s
Submitter: %s
Branch: %s
Bug(s): %s\n''' % (change_url, gitorious_url, submitter, branch, ', '.join(bugs))
Branch: %s\n''' % (change_url, gitorious_url, submitter, branch)
msg = MIMEText(body + '\n' + git_log)
msg['Subject'] = 'A change has been merged'
msg['From'] = FROM_ADDRESS
msg['To'] = TO_ADDRESS
msg['To'] = to_address
s = smtplib.SMTP()
s.connect()
s.sendmail(FROM_ADDRESS, [TO_ADDRESS], msg.as_string())
s.sendmail(FROM_ADDRESS, [to_address], msg.as_string())
s.quit()
def main():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment