From 1afd1bcf923abfa0e97cc98c392b380afcec6189 Mon Sep 17 00:00:00 2001 From: Ben Bader Date: Sun, 20 Jun 2021 21:04:47 -0700 Subject: [PATCH] Add missing license headers and a script to check that new files have them (#450) Add missing license headers and a script to check that new files have them --- .github/workflows/pre-merge.yml | 5 +++++ script/ensure_license_headers.sh | 9 +++++++++ .../kotlin/com/microsoft/thrifty/kgen/util.kt | 20 +++++++++++++++++++ .../kotlin/com/microsoft/thrifty/KtApi.kt | 20 +++++++++++++++++++ .../thrifty/service/AsyncClientBase.kt | 20 +++++++++++++++++++ .../schema/parser/ParserErrorListener.kt | 20 +++++++++++++++++++ 6 files changed, 94 insertions(+) create mode 100755 script/ensure_license_headers.sh diff --git a/.github/workflows/pre-merge.yml b/.github/workflows/pre-merge.yml index 9f44379..ab8e2a4 100644 --- a/.github/workflows/pre-merge.yml +++ b/.github/workflows/pre-merge.yml @@ -39,6 +39,11 @@ jobs: cache-gradle-${{ matrix.os }}-${{ matrix.jvm-version }}-${{ hashFiles('settings.gradle') }} cache-gradle-${{ matrix.os }}k-${{ matrix.jvm-version }} + - name: Ensure all code files have license headers + shell: bash + run: | + ./script/ensure_license_headers.sh + - name: Set up JDK uses: actions/setup-java@v1 with: diff --git a/script/ensure_license_headers.sh b/script/ensure_license_headers.sh new file mode 100755 index 0000000..7a2b069 --- /dev/null +++ b/script/ensure_license_headers.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +LINES="$(grep -E "Copyright \((c|C)\)" -rL --include=\*.kt --exclude-dir=generated-src --exclude-dir=projects .)" +STR_LEN=${#LINES} +if (( $STR_LEN > 0 )); then + echo "These files seem to be missing a license header:" + echo $LINES + exit 1 +fi diff --git a/thrifty-kotlin-codegen/src/test/kotlin/com/microsoft/thrifty/kgen/util.kt b/thrifty-kotlin-codegen/src/test/kotlin/com/microsoft/thrifty/kgen/util.kt index 0d32138..1dea2e6 100644 --- a/thrifty-kotlin-codegen/src/test/kotlin/com/microsoft/thrifty/kgen/util.kt +++ b/thrifty-kotlin-codegen/src/test/kotlin/com/microsoft/thrifty/kgen/util.kt @@ -1,3 +1,23 @@ +/* + * Thrifty + * + * Copyright (c) Microsoft Corporation + * + * All rights reserved. + * + * 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 + * + * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING + * WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, + * FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. + * + * See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. + */ package com.microsoft.thrifty.kgen import com.squareup.kotlinpoet.FileSpec diff --git a/thrifty-runtime/src/commonMain/kotlin/com/microsoft/thrifty/KtApi.kt b/thrifty-runtime/src/commonMain/kotlin/com/microsoft/thrifty/KtApi.kt index 0842e67..398389d 100644 --- a/thrifty-runtime/src/commonMain/kotlin/com/microsoft/thrifty/KtApi.kt +++ b/thrifty-runtime/src/commonMain/kotlin/com/microsoft/thrifty/KtApi.kt @@ -1,3 +1,23 @@ +/* + * Thrifty + * + * Copyright (c) Microsoft Corporation + * + * All rights reserved. + * + * 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 + * + * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING + * WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, + * FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. + * + * See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. + */ package com.microsoft.thrifty import com.microsoft.thrifty.protocol.BinaryProtocol diff --git a/thrifty-runtime/src/commonMain/kotlin/com/microsoft/thrifty/service/AsyncClientBase.kt b/thrifty-runtime/src/commonMain/kotlin/com/microsoft/thrifty/service/AsyncClientBase.kt index 4bb89ed..8afa466 100644 --- a/thrifty-runtime/src/commonMain/kotlin/com/microsoft/thrifty/service/AsyncClientBase.kt +++ b/thrifty-runtime/src/commonMain/kotlin/com/microsoft/thrifty/service/AsyncClientBase.kt @@ -1,3 +1,23 @@ +/* + * Thrifty + * + * Copyright (c) Microsoft Corporation + * + * All rights reserved. + * + * 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 + * + * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING + * WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, + * FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. + * + * See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. + */ package com.microsoft.thrifty.service import com.microsoft.thrifty.protocol.Protocol diff --git a/thrifty-schema/src/main/kotlin/com/microsoft/thrifty/schema/parser/ParserErrorListener.kt b/thrifty-schema/src/main/kotlin/com/microsoft/thrifty/schema/parser/ParserErrorListener.kt index 99fe784..8be7f20 100644 --- a/thrifty-schema/src/main/kotlin/com/microsoft/thrifty/schema/parser/ParserErrorListener.kt +++ b/thrifty-schema/src/main/kotlin/com/microsoft/thrifty/schema/parser/ParserErrorListener.kt @@ -1,3 +1,23 @@ +/* + * Thrifty + * + * Copyright (c) Microsoft Corporation + * + * All rights reserved. + * + * 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 + * + * THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING + * WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, + * FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. + * + * See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. + */ package com.microsoft.thrifty.schema.parser import com.microsoft.thrifty.schema.ErrorReporter