cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# CDDL HEADER START
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# The contents of this file are subject to the terms of the
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# Common Development and Distribution License (the "License").
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# You may not use this file except in compliance with the License.
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# See the License for the specific language governing permissions
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# and limitations under the License.
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# When distributing Covered Code, include this CDDL HEADER in each
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# If applicable, add the following below this CDDL HEADER, with the
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# fields enclosed by brackets "[]" replaced with your own identifying
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# information: Portions Copyright [yyyy] [name of copyright owner]
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# CDDL HEADER END
41a5f560d7437bb41abade5dce25dc6875da156aMark J. Nelson# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# Use is subject to license terms.
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe# Copyright 2007, 2010 Richard Lowe
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# Check delta comments:
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# - Have the correct form.
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe# - Have a synopsis matching that of the bug
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson# - Appear only once.
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowedef comchk(comments, check_db=True, output=sys.stderr):
c08a253caa7a003446506d7c1d6da5345e61aebeJohn Sonnenschein '''Validate checkin comments against ON standards.
c08a253caa7a003446506d7c1d6da5345e61aebeJohn Sonnenschein Comments must be a list of one-line comments, with no trailing
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe If check_db is True (the default), validate bug synopses against the
c08a253caa7a003446506d7c1d6da5345e61aebeJohn Sonnenschein Error messages intended for the user are written to output,
c08a253caa7a003446506d7c1d6da5345e61aebeJohn Sonnenschein which defaults to stderr
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe r'Portions contributed by|' +
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe r'Contributed by|' +
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe r'Reviewed[ -]by|' +
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe r'Approved[ -]by|' +
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe r'back[ -]?out)' +
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson 'mutant': [],
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson 'nomatch': [],
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson 'nonexistent': [] }
c08a253caa7a003446506d7c1d6da5345e61aebeJohn Sonnenschein # Our input must be newline-free, comments are line-wise.
c08a253caa7a003446506d7c1d6da5345e61aebeJohn Sonnenschein raise ValueError("newline in comment '%s'" % com)
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson # Ignore valid comments we can't check
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson # Bugs missing a space after the ID are still bugs
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson # for the purposes of the duplicate ID and synopsis
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson # Anything else is bogus
ef62fef3e05c4489eec0a36d605736821d778929Richard Lowe # For each synopsis, compare the real synopsis with
ef62fef3e05c4489eec0a36d605736821d778929Richard Lowe # that in the comments, allowing for possible '(fix
ef62fef3e05c4489eec0a36d605736821d778929Richard Lowe # stuff)'-like trailing text
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson output.write("WARNING: Blank line(s) in comments\n")
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson output.write("These IDs appear more than once in your "
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson "comments:\n")
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson output.write("These bugs are missing a single space following "
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson "the ID:\n")
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe output.write("These comments are not valid bugs:\n")
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe output.write("These bugs were not found in the databases:\n")
cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0mjnelson "the database entries:\n")
2f54b716e4d3cb0dc99066638fed631e3cbec97cRichard Lowe output.write("Synopsis of %s is wrong:\n" % err[0])