#!/usr/bin/env python
# Copyright (c) 2012 OpenStack, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

# This is designed to be called by a gerrit hook.  It searched new
# patchsets for strings like "bug FOO" and updates corresponding Launchpad
# bugs status.

import argparse
import re
import subprocess
import smtplib

from email.mime.text import MIMEText

BASE_DIR = '/home/gerrit2/review_site'
EMAIL_TEMPLATE = """
Hi, I'd like you to take a look at this patch for potential
documentation impact.
%s

Log:
%s
"""
DEST_ADDRESS = 'openstack-docs@lists.openstack.org'

def process_impact(git_log, args):
    """Notify doc team of doc impact"""
    email_content = EMAIL_TEMPLATE % (args.change_url, git_log)
    msg = MIMEText(email_content)
    msg['Subject'] = '[%s] DocImpact review request change %s' % \
        (args.project, args.change)
    msg['From'] = 'gerrit2@review.openstack.org'
    msg['To'] = DEST_ADDRESS

    s = smtplib.SMTP('localhost')
    s.sendmail('gerrit2@review.openstack.org', DEST_ADDRESS, msg.as_string())
    s.quit()

def docs_impacted(git_log):
    """Determine if a changes log indicates there is a doc impact"""
    impact_regexp = r'DocImpact'
    return re.search(impact_regexp, git_log, re.IGNORECASE)

def extract_git_log(args):
    """Extract git log of all merged commits"""
    cmd = ['git',
           '--git-dir=' + BASE_DIR + '/git/' + args.project + '.git',
           'log', '--no-merges', args.commit + '^1..' + args.commit]
    return subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('hook')
    #common
    parser.add_argument('--change', default=None)
    parser.add_argument('--change-url', default=None)
    parser.add_argument('--project', default=None)
    parser.add_argument('--branch', default=None)
    parser.add_argument('--commit', default=None)
    #change-merged
    parser.add_argument('--submitter', default=None)
    #patchset-created
    parser.add_argument('--uploader', default=None)
    parser.add_argument('--patchset', default=None)

    args = parser.parse_args()

    # Get git log
    git_log = extract_git_log(args)

    # Process doc_impacts found in git log
    if docs_impacted(git_log):
        process_impact(git_log, args)


if __name__ == '__main__':
    main()
