mdedetrich commented on code in PR #50: URL: https://github.com/apache/incubator-pekko/pull/50#discussion_r1023983038
########## project/CopyrightHeader.scala: ########## @@ -40,60 +59,61 @@ trait CopyrightHeader extends AutoPlugin { (Test / compile).value }) - // We hard-code this so PR's created in year X will not suddenly fail in X+1. - // Of course we should remember to update it early in the year. - val CurrentYear = "2022" - val CopyrightPattern = "Copyright \\([Cc]\\) (\\d{4}([-–]\\d{4})?) (Lightbend|Typesafe) Inc. <.*>".r - val CopyrightHeaderPattern = s"(?s).*${CopyrightPattern}.*".r - def headerFor(year: String): String = s"Copyright (C) $year Lightbend Inc. <https://www.lightbend.com>" - val cStyleComment = HeaderCommentStyle.cStyleBlockComment.copy(commentCreator = new CommentCreator() { - - def updateLightbendHeader(header: String): String = header match { - case CopyrightHeaderPattern(years, null, _) => - if (years != CurrentYear) - CopyrightPattern.replaceFirstIn(header, headerFor(years + "-" + CurrentYear)) - else - CopyrightPattern.replaceFirstIn(header, headerFor(years)) - case CopyrightHeaderPattern(years, endYears, _) => - CopyrightPattern.replaceFirstIn(header, headerFor(years.replace(endYears, "-" + CurrentYear))) - case _ => - header - } + def apacheHeader: String = + """Licensed to the Apache Software Foundation (ASF) under one + |or more contributor license agreements. See the NOTICE file + |distributed with this work for additional information + |regarding copyright ownership. The ASF licenses this file + |to you 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. + |""".stripMargin - def parseStartAndEndYear(header: String): Option[(String, Option[String])] = header match { - case CopyrightHeaderPattern(years, null, _) => - Some((years, None)) - case CopyrightHeaderPattern(years, endYears, _) => - Some((years, Some(endYears))) - case _ => - None - } + val cStyleComment = HeaderCommentStyle.cStyleBlockComment.copy(commentCreator = new CommentCreator() { override def apply(text: String, existingText: Option[String]): String = { val formatted = existingText match { + case Some(existedText) if isValidCopyRightAnnotated(existedText) => + existedText case Some(existedText) => - parseStartAndEndYear(existedText) match { - case Some((years, None)) => - if (years != CurrentYear) { - val header = headerFor(years + "-" + CurrentYear) - HeaderCommentStyle.cStyleBlockComment.commentCreator(header, existingText) - } else { - HeaderCommentStyle.cStyleBlockComment.commentCreator(headerFor(CurrentYear), existingText) - } - case Some((years, Some(endYears))) => - val header = headerFor(years.replace(endYears, "-" + CurrentYear)) - HeaderCommentStyle.cStyleBlockComment.commentCreator(header, existingText) - case None => - existedText - } + throw new IllegalStateException(s"Unable to detect copyright for header:[${existedText}]") Review Comment: Well I would say an exception here is appropriate because otherwise it opens ourselves up to legal issues, also a warning would essentially be ignored by the CI. If this exception is thrown we should actually investigate what is going on. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org For additional commands, e-mail: notifications-h...@pekko.apache.org