RFR: 827: Copyright year differences can be regarded as a clean backport [v3]

Erik Joelsson erikj at openjdk.org
Wed Sep 20 21:04:45 UTC 2023


On Wed, 20 Sep 2023 16:30:01 GMT, Zhao Song <zsong at openjdk.org> wrote:

>> vcs/src/main/java/org/openjdk/skara/vcs/DiffComparator.java line 32:
>> 
>>> 30:     private static final Pattern COPYRIGHT_PATTERN = Pattern.compile("""
>>> 31:             -(.)*Copyright \\(c\\) (?:\\d|\\s|,)* Oracle and/or its affiliates\\. All rights reserved\\.
>>> 32:             \\+(.)*Copyright \\(c\\) (?:\\d|\\s|,)* Oracle and/or its affiliates\\. All rights reserved\\.
>> 
>> If the only difference between these lines is the first character, we should only need one line.
>> Suggestion:
>> 
>>             [-+](.)*Copyright \(c\) (?:\\d|\\s|,)* Oracle and/or its affiliates\. All rights reserved\.
>
> But if we only use one line like you suggested, this will introduce a problem. In the backport PR, the user could make any change to the first line of copyright.  For example, the user could change the first line to "Random line" and the backport pr would still be considered as clean backport.  
> 
> Because the hunk will be 
> 
> @@ -2,1 +2,1 @@
> - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
> + * Random line.
> 
> and this hunk would match the regex pattern and be filtered out.
> 
> 
> I think we still need two lines to make sure the user **only** changes the copyright years.

Ah I get it now, this is a multiline pattern, not an either this line or that line. I thought you needed to tell something in the Java regex API that it was multiline, but maybe you don't if the pattern has a newline in it?

-------------

PR Review Comment: https://git.openjdk.org/skara/pull/1556#discussion_r1332180231


More information about the skara-dev mailing list