You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by GitBox <gi...@apache.org> on 2022/11/16 09:47:51 UTC

[GitHub] [incubator-pekko] mdedetrich commented on a diff in pull request #50: !sbt Use apache header for new files.

mdedetrich commented on code in PR #50:
URL: https://github.com/apache/incubator-pekko/pull/50#discussion_r1023764357


##########
project/CopyrightHeader.scala:
##########
@@ -40,55 +40,34 @@ 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) =>
-          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
-          }
+          existedText
         case None =>
           HeaderCommentStyle.cStyleBlockComment.commentCreator(text, existingText)
       }

Review Comment:
   > If there is a copyright statement do not modify the file.
   
   As far as I can tell, every single source file in this project already has a copyright statement so
   
   > If there is no copyright statement there should be an Apache V2 text block. If it is not there insert it.
   
   Is never going to happen until we add new source files (which hasn't happened yet).



-- 
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-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org