CheckPrecommit.java revision 3852
1344N/A * The contents of this file are subject to the terms of the 1344N/A * Common Development and Distribution License, Version 1.0 only 1344N/A * (the "License"). You may not use this file except in compliance 1344N/A * You can obtain a copy of the license at 1344N/A * See the License for the specific language governing permissions 1344N/A * and limitations under the License. 1344N/A * When distributing Covered Code, include this CDDL HEADER in each 1344N/A * file and include the License file at 1344N/A * add the following below this CDDL HEADER, with the fields enclosed 1344N/A * by brackets "[]" replaced with your own identifying information: 1344N/A * Portions Copyright [yyyy] [name of copyright owner] 3231N/A * Copyright 2008 Sun Microsystems, Inc. 1344N/A * This class provides an implementation of an Ant task that may be used to 1344N/A * perform various checks to deteermine whether a file is suitable to be 1344N/A * committed. This includes: 1344N/A * <LI>Make sure that the file has the correct "svn:eol-style" property 1344N/A * <LI>If a file contains a line that appears to be a comment and includes the 1344N/A * word "copyright", then it should contain the current year.</LI> 1344N/A * The name of the system property that may be used to prevent copyright date 1344N/A * problems from failing the build. 1344N/A "org.opends.server.IgnoreCopyrightDateErrors";
1520N/A * The name of the system property that may be used to prevent svn eol-style 1344N/A * problems from failing the build. 1344N/A "org.opends.server.IgnoreEOLStyleErrors";
1344N/A // The path to the directory that is the base of the workspace. 1344N/A // The set of files that appear to have problems with the EOL style. 1344N/A // The set of files that appear to have problems with the copyright date. 1344N/A // The path to the root of the Subversion workspace to check. 1344N/A // The string representation of the current year. 3852N/A // The overall SVN Client Manager. required with svnkit 1.2.x 1344N/A // The property client used to look at file properties. 1344N/A * Specifies the path to the root of the Subversion workspace for which to 1344N/A * retrieve the revision number. 1344N/A * @param workspace The path to the root of the Subversion workspace for 1344N/A * which to retrieve the revision number. 1344N/A * Performs the appropriate processing needed for this task. In this case, 1344N/A * it uses SVNKit to identify all modified files in the current workspace. 1344N/A * For all source files, look for comment lines containing the word 1344N/A * "copyright" and make sure at least one of them contains the current year. 1344N/A // Get the year to use in the determination. 1344N/A // Process the base directory and all of its subdirectories. 1344N/A "Subversion status: " + e);
1344N/A "for the following files:");
1707N/A "=true' to ignore svn eol-style warnings.");
1344N/A "for the following files:");
1707N/A "=true' to ignore copyright warnings.");
1344N/A * Examines the provided status item to determine whether the associated file 1344N/A * @param status The SVN status information for the file of interest. 1344N/A // The file doesn't exist (which probably means it's been deleted) or 1344N/A // isn't a regular file, so we'll ignore it. 1344N/A // The file doesn't have an extension that we care about, so skip it. 1344N/A // The file doesn't have an extension. We'll still want to check it if 1344N/A // Check to make sure that the file has the correct EOL style. 1344N/A // This could happen if the file isn't under version control. If so, then 1344N/A // we can't check the eol-style but we should at least be able to check 1344N/A // the copyright dates, so keep going. 1344N/A // Check to see whether the file has a comment line containing a copyright 1344N/A // without the current year. 1344N/A " to check copyright date.");
1344N/A * Indicates whether the provided line appears to be a comment line. It will 1344N/A * check for a number of common comment indicators in Java source files, 1344N/A * shell scripts, XML files, and LDIF files. 1344N/A * @param lowerLine The line to be checked. It should have been coverted to 1344N/A * all lowercase characters and any leading spaces 1344N/A * @return {@code true} if it appears that the line is a comment line, or