Final update copyright headers to reference license files at the repo root (#1693)

* Final update copyright headers to reference license files at the repo root

Signed-off-by: spham <spham@amazon.com>

* Fix copyright validator unit tests to support the stale O3DE header scenario

Signed-off-by: spham <spham@amazon.com>
This commit is contained in:
Steve Pham
2021-06-30 19:51:55 -07:00
committed by GitHub
parent 7b1c37f296
commit b4a2edec6a
18020 changed files with 18059 additions and 18042 deletions
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
"""
Copyright (c) Contributors to the Open 3D Engine Project
Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT#
#
@@ -13,19 +13,19 @@ from commit_validation.validators.copyright_header_validator import CopyrightHea
class CopyrightHeaderValidatorTests(unittest.TestCase):
@patch('builtins.open', mock_open(read_data='This file does contain\n'
'Copyright (c) Contributors to the Open 3D Engine Project, so it should pass\n'))
'Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution., so it should pass\n'))
def test_fileWithCopyrightHeader_passes(self):
commit = MockCommit(files=['/someCppFile.cpp'])
files = [
'This file does contain\n'
'Copyright (c) Contributors to the Open 3D Engine Project, so it should pass\n',
'Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution., so it should pass\n',
'This file does contain\n'
'Copyright(c) Contributors to the Open 3D Engine Project, so it should pass\n'
'Copyright(c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution., so it should pass\n'
'and there\'s no space between "Copyright" and "(c)"',
'This file has a upper-case C between the parenthesis\n'
'// Copyright (C) Contributors to the Open 3D Engine Project.',
'// Copyright (C) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.',
]
for file in files:
with patch('builtins.open', mock_open(read_data=file)):
@@ -63,6 +63,14 @@ class CopyrightHeaderValidatorTests(unittest.TestCase):
self.assertFalse(CopyrightHeaderValidator().run(commit, error_list))
self.assertNotEqual(len(error_list), 0, f"Errors were expected but none were returned.")
@patch('builtins.open', mock_open(read_data='Copyright (c) Contributors to the Open 3D Engine Project.\n'
'******************\n'.format(' ')))
def test_fileWithStaleO3DECopyrightHeader_fails(self):
commit = MockCommit(files=['/someCppFile.cpp'])
error_list = []
self.assertFalse(CopyrightHeaderValidator().run(commit, error_list))
self.assertNotEqual(len(error_list), 0, f"Errors were expected but none were returned.")
@patch('builtins.open', mock_open(read_data='This file does contains legacy header\n'
'Copyright{0}Crytek\n'.format(' ')))
def test_fileWithCrytekCopyrightHeader_fails(self):
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -11,7 +11,8 @@ from typing import Type, List
from commit_validation.commit_validation import Commit, CommitValidator, IsFileSkipped, SOURCE_AND_SCRIPT_FILE_EXTENSIONS, EXCLUDED_VALIDATION_PATTERNS, VERBOSE
OPEN_3D_ENGINE_PATTERN = re.compile(r'copyright[\s]*(?:\(c\))?[\s]*.*?Contributors\sto\sthe\sOpen\s3D\sEngine\sProject', re.IGNORECASE | re.DOTALL)
OPEN_3D_ENGINE_PATTERN_STALE = re.compile(r'copyright[\s]*(?:\(c\))?[\s]*.*?Contributors\sto\sthe\sOpen\s3D\sEngine\sProject\s*$', re.IGNORECASE | re.DOTALL)
OPEN_3D_ENGINE_PATTERN = re.compile(r'copyright[\s]*(?:\(c\))?[\s]*.*?Contributors\sto\sthe\sOpen\s3D\sEngine\sProject\.\sFor\scomplete\scopyright\sand\slicense\sterms\splease\ssee\sthe\sLICENSE\sat\sthe\sroot\sof\sthis\sdistribution\.', re.IGNORECASE | re.DOTALL)
AMAZON_ORIGINAL_COPYRIGHT_PATTERN = re.compile(r'.*?this\sfile\sCopyright\s*\(c\)\s*Amazon\.com.*?', re.IGNORECASE | re.DOTALL)
AMAZON_MODIFICATION_COPYRIGHT_PATTERN = re.compile(r'.*?Modifications\scopyright\sAmazon\.com', re.IGNORECASE | re.DOTALL)
CRYTEK_COPYRIGHT_PATTERN = re.compile(r'Copyright Crytek', re.MULTILINE)
@@ -49,10 +50,12 @@ class CopyrightHeaderValidator(CommitValidator):
has_amazon_mod_pattern = False
has_crytek_pattern = False
has_original_amazon_copyright_pattern = False
has_stale_o3de_pattern = False
with open(file_name, 'rt', encoding='utf8', errors='replace') as fh:
for line in fh:
if OPEN_3D_ENGINE_PATTERN_STALE.search(line):
has_stale_o3de_pattern = True
if OPEN_3D_ENGINE_PATTERN.search(line):
has_o3de_pattern = True
elif AMAZON_ORIGINAL_COPYRIGHT_PATTERN.search(line):
@@ -74,6 +77,12 @@ class CopyrightHeaderValidator(CommitValidator):
if VERBOSE: print(error_message)
errors.append(error_message)
if has_stale_o3de_pattern:
# Has the stale the O3DE copyright (without the 'For complete copyright...')
error_message = str(f"{file_name}::{self.__class__.__name__} FAILED - Source file O3DE copyright header missing 'For complete copyright...'")
if VERBOSE: print(error_message)
errors.append(error_message)
if not has_o3de_pattern:
# Missing the O3DE copyright AND does not have the Amazon Modifications copyright, assuming that this file is missing valid copyrights in general
error_message = str(f'{file_name}::{self.__class__.__name__} FAILED - Source file missing O3DE copyright header.')
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
@@ -1,5 +1,5 @@
#
# Copyright (c) Contributors to the Open 3D Engine Project
# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#