Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checks for license presence while disregarding '#\n' #237

Merged
merged 3 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/ci/test_static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ flake8 --append-config=./.flake8 ./scripts/ci/*.py

# Other static checks
python ./scripts/ci/verify_codeowners.py
python ./scripts/ci/verify_license.py 'src/storage-preview/azext_storage_preview/vendored_sdks'
python ./scripts/ci/verify_license.py
21 changes: 4 additions & 17 deletions scripts/ci/verify_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,8 @@
REPO_ROOT = get_repo_root()
SRC_DIR = os.path.join(REPO_ROOT, 'src')

LICENSE_HEADER = """# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
"""

AUTOREST_LICENSE_HEADER = """# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
"""
LICENSE_HEADER = ("Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. "
"See License.txt in the project root for license information.")


def main(args):
Expand All @@ -45,7 +31,8 @@ def main(args):
for python_file in file_itr:
with open(python_file, 'r') as f:
file_text = f.read().replace('\r\n', '\n')
if file_text and (LICENSE_HEADER not in file_text and AUTOREST_LICENSE_HEADER not in file_text):
file_text = file_text.replace('\n#', '')
if file_text and (LICENSE_HEADER not in file_text):
files_without_header.append(os.path.join(current_dir, python_file))

if files_without_header:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

__import__('pkg_resources').declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
__import__('pkg_resources').declare_namespace(__name__)
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------