summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-06-14 21:01:08 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2022-08-05 14:48:25 +0200
commit4d8ee117f94b863fa91b258ba4eda89492571cdc (patch)
tree2f15c0c3308c9b7ee3663f1e2b48c91796ca0a49 /scripts
parentec9e828d13008d8df26cf8e5fa276b09ee188a26 (diff)
downloadqtqa-4d8ee117f94b863fa91b258ba4eda89492571cdc.tar.gz
Fix handling of transition to SPDX headers
The old header extended two lines after the token by which it was recognized, which never mattered before (because changes to the copyright header would still leave it with those two lines at the end) but, of course, they matter now. The precise matching of the end also matters. The conversion to SPDX also added some start-comment markers between the SPDX header and further commentary, where the old header continued on to such, notably in the glgen-generated header files. Task-number: QTQAINFRA-5013 Change-Id: I7b8c3e174a350a3509837f155001b79930f485ca Reviewed-by: Lucie Gerard <lucie.gerard@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/api-review/resetboring.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/scripts/api-review/resetboring.py b/scripts/api-review/resetboring.py
index 2803332..68806a9 100755
--- a/scripts/api-review/resetboring.py
+++ b/scripts/api-review/resetboring.py
@@ -115,10 +115,12 @@ class Selector(object): # Select interesting changes, discard boring.
@staticmethod
def __end_copyright(seq, oldMarker='_'.join(('$QT', 'END', 'LICENSE$')),
spdxHeader='-'.join(('SPDX', 'License', 'Identifier:'))):
- """Line number of the end of the copyright banner"""
- for i, line in enumerate(seq):
- if spdxHeader in line or oldMarker in line:
+ """Line number just after the end of the copyright banner"""
+ for i, line in enumerate(seq, 1):
+ if spdxHeader in line:
return i
+ if oldMarker in line:
+ return i + 2
return 0
from difflib import SequenceMatcher
@@ -265,10 +267,20 @@ class Selector(object): # Select interesting changes, discard boring.
if startNew < self.__headNew and startOld < self.__headOld:
# This hunk is *partially* copyright.
# Take copyright header part from old, ...
- if endOld > self.__headOld:
+ if endOld >= self.__headOld:
self.__hybrid += self.__old[startOld:self.__headOld]
startOld, startNew = self.__headOld, self.__headNew
- assert endOld > startOld or endNew > startNew
+ # <Kludge>: before the SPDX conversion, some copyright
+ # headers sequed straight into a "generated file" banner, so
+ # a comment start was inserted.
+ tail = self.__new[startNew]
+ if (self.__hybrid[-1] == '**'
+ and tail.startswith('/*') and tail.rstrip('*') == '/'
+ and self.__new[startNew + 1] == self.__old[startOld]):
+ # Skip over the comment marker, tail.
+ startNew += 1
+ # </Kludge> (except for the next line's >= to accommodate the kludge)
+ assert endOld > startOld or endNew >= startNew
# ... put the (rest of the) block back in the queue:
hunk.insert(0, (tag, startOld, endOld, startNew, endNew))