From 95ed0a621082a94b67c0d90651a991a66a22e038 Mon Sep 17 00:00:00 2001 From: Chris Li <76067158+666lcz@users.noreply.github.com> Date: Thu, 24 Mar 2022 15:41:49 -0700 Subject: [PATCH] Add license check for move, typescript, javascript files (#1051) --- explorer/client/.eslintrc.js | 3 +++ explorer/client/tailwind.config.js | 3 +++ .../src/sdk/gateway-generated-schema.ts | 3 +++ scripts/license_check.sh | 15 ++++++++------- .../examples/defi/tests/EscrowTests.move | 3 +++ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/explorer/client/.eslintrc.js b/explorer/client/.eslintrc.js index c940525521350..d4b1257c7e59e 100644 --- a/explorer/client/.eslintrc.js +++ b/explorer/client/.eslintrc.js @@ -1,3 +1,6 @@ +// Copyright (c) 2022, Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + module.exports = { extends: ['react-app', 'react-app/jest', 'prettier'], rules: { diff --git a/explorer/client/tailwind.config.js b/explorer/client/tailwind.config.js index f6ef4d803125f..3caacffff6f95 100644 --- a/explorer/client/tailwind.config.js +++ b/explorer/client/tailwind.config.js @@ -1,3 +1,6 @@ +// Copyright (c) 2022, Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + const defaultTheme = require('tailwindcss/defaultTheme'); module.exports = { diff --git a/nft_mirror/oracle_server/src/sdk/gateway-generated-schema.ts b/nft_mirror/oracle_server/src/sdk/gateway-generated-schema.ts index e7b74bfadfee0..9d0ba0b3444d9 100644 --- a/nft_mirror/oracle_server/src/sdk/gateway-generated-schema.ts +++ b/nft_mirror/oracle_server/src/sdk/gateway-generated-schema.ts @@ -1,3 +1,6 @@ +// Copyright (c) 2022, Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + /** * This file was auto-generated by openapi-typescript. * Do not make direct changes to the file. diff --git a/scripts/license_check.sh b/scripts/license_check.sh index d70348aae8ffc..1596e69b769fa 100755 --- a/scripts/license_check.sh +++ b/scripts/license_check.sh @@ -1,5 +1,5 @@ #!/bin/bash -# shellcheck disable=SC2044 +# shellcheck disable=SC2044,SC2086,SC2016 # This script checks each file starts with a license comment set -e set -o pipefail @@ -7,14 +7,15 @@ set -o pipefail DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" TOPLEVEL="${DIR}/../" -# Iterate over rust files not in the target directory -for i in $(find "$TOPLEVEL" -path "$TOPLEVEL/target" -prune -o -iname "*.rs" -print) +# Iterate over files in the repo that satisfy the following rules +# 1. File extension is one of .(move | rs | tsx | ts | js) +# 2. File directory is not '$TOPLEVEL/target' or "**/build" or "**/node_modules" +for i in $(find $TOPLEVEL -type d \( -path '$TOPLEVEL/target' -o -name 'node_modules' -o -name 'build' \) -prune -o \( -iname '*.rs' -o -iname '*.move' -o -iname '*.tsx' -o -iname '*.ts' -o -iname '*.js' \) -print) do - CNT=$(head -n3 "$i" | grep -oEe '// (Copyright \(c\) 2022, Mysten Labs, Inc.|SPDX-License-Identifier: Apache-2.0)' | wc -l) - # echo "$i $CNT" + CNT=$(head -n3 "$i" | grep -oEe '// (Copyright \(c\) 2022, Mysten Labs, Inc.|SPDX-License-Identifier: Apache-2.0)' | wc -l) || true if [ "$CNT" -lt 2 ] then - echo "File $i has an incorrect license header" - exit 1 + echo "File $i has an incorrect license header" + exit 1 fi done diff --git a/sui_programmability/examples/defi/tests/EscrowTests.move b/sui_programmability/examples/defi/tests/EscrowTests.move index 32a2d12fe26e6..59a6cf1dfec3c 100644 --- a/sui_programmability/examples/defi/tests/EscrowTests.move +++ b/sui_programmability/examples/defi/tests/EscrowTests.move @@ -1,3 +1,6 @@ +// Copyright (c) 2022, Mysten Labs, Inc. +// SPDX-License-Identifier: Apache-2.0 + #[test_only] module DeFi::EscrowTests { use Sui::ID::{Self, VersionedID};