Skip to content
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
25 changes: 20 additions & 5 deletions hack/add_license_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@
#
# SPDX-License-Identifier: Apache-2.0

# set interactive mode to enable defining a gsed alias
shopt -s expand_aliases

if [[ "$OSTYPE" == "linux-gnu"* ]]; then # Linux
alias gsed="sed -i"
elif [[ "$OSTYPE" == "darwin"* ]]; then # macOS
alias gsed="sed -i ''"
elif [[ "$OSTYPE" == "cygwin" ]]; then # POSIX compatible emulation for Windows
alias gsed="sed -i"
else
echo "FAILED. OS not compatible with script '/hack/add_license_headers.sh'"
exit 1
fi
export gsed

hash_comment () {
echo "$1"
if ! grep -q "SPDX-License-Identifier" "$1"
then
sed -i '' '1i\
gsed '1i\
# Copyright 2021 The MLX Contributors\
#\
# SPDX-License-Identifier: Apache-2.0\
Expand All @@ -20,7 +35,7 @@ slash_comment () {
echo "$1"
if ! grep -q "SPDX-License-Identifier" "$1"
then
sed -i '' '1i\
gsed '1i\
// Copyright 2021 The MLX Contributors\
//\
// SPDX-License-Identifier: Apache-2.0\
Expand All @@ -32,7 +47,7 @@ css_comment () {
echo "$1"
if ! grep -q "SPDX-License-Identifier" "$1"
then
sed -i '' '1i\
gsed '1i\
/*\
* Copyright 2021 The MLX Contributors\
*\
Expand All @@ -46,7 +61,7 @@ html_comment () {
echo "$1"
if ! grep -q "SPDX-License-Identifier" "$1"
then
sed -i '' '1i\
gsed '1i\
<!--\
Copyright 2021 The MLX Contributors\
\
Expand All @@ -64,7 +79,7 @@ echo "Adding missing license headers"
find . -type f -not -path '*/temp/*' -a -not -path '*/\.*' -a \( -name '*.py' -o -name '*.yaml' -o -name '*.yml' -o -name '*.sh' \) -exec bash -c 'hash_comment "$0"' {} \;

# Javascript
find . -type f -not -path '*/node_modules/*' -a -not -path '*/temp/*' -a -not -path '*/\.*' -a \( -name '*.js' -o -name '*.ts' \) -exec bash -c 'slash_comment "$0"' {} \;
find . -type f -not -path '*/node_modules/*' -a -not -path '*/temp/*' -a -not -path '*/\.*' -a -not -path '*.bundle.js' -a \( -name '*.js' -o -name '*.ts' \) -exec bash -c 'slash_comment "$0"' {} \;

# CSS
find . -type f -not -path '*/temp/*' -a -not -path '*/\.*' -a \( -name '*.css' -o -name '*.tsx' \) -exec bash -c 'css_comment "$0"' {} \;
Expand Down
14 changes: 2 additions & 12 deletions hack/regenerate_catalog_upload_json.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
#!/usr/bin/env python3

# Copyright 2021 IBM Corporation
# Copyright 2021 The MLX Contributors
#
# Licensed 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.
# SPDX-License-Identifier: Apache-2.0

from __future__ import print_function

Expand Down