Skip to content

Commit

Permalink
Improve License Header Check (opensearch-project#78)
Browse files Browse the repository at this point in the history
* Correctly handle expected license headers of differing lengths

Signed-off-by: Thomas Farr <[email protected]>

* Shorten expected license header

Signed-off-by: Thomas Farr <[email protected]>

* Fix `*.cs` license header blocks to match expected.

```sh
perl -i -p0e 's|license\.\n\*\n\* Modifications|license.\n*/\n/*\n* Modifications|s' $(find . -iname '*.cs')
```

Signed-off-by: Thomas Farr <[email protected]>

Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
tfarrep authored Aug 31, 2022
1 parent 835c266 commit 6703cd4
Show file tree
Hide file tree
Showing 2,443 changed files with 4,886 additions and 2,486 deletions.
11 changes: 6 additions & 5 deletions .github/check-license-headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ set -o errexit
set -o pipefail

TOP=$(cd "$(dirname "$0")/.." >/dev/null && pwd)
NLINES=$(wc -l .github/license-header.txt | awk '{print $1}')
NLINES_CS=$(wc -l .github/license-header.txt | awk '{print $1}')
NLINES_FS=$(wc -l .github/license-header-fs.txt | awk '{print $1}')

function check_license_header {
local f
f=$1
if [[ $f == *.fs ]] && ! diff -a --strip-trailing-cr .github/license-header-fs.txt <(head -$NLINES "$f") >/dev/null; then
if [[ $f == *.fs ]] && ! diff -a --strip-trailing-cr .github/license-header-fs.txt <(head -$NLINES_FS "$f") >/dev/null; then
echo $f
echo "check-license-headers: error: '$f' does not have required license header, see 'diff -u .github/license-header-fs.txt <(head -$NLINES $f)'"
echo "check-license-headers: error: '$f' does not have required license header, see 'diff -u .github/license-header-fs.txt <(head -$NLINES_FS $f)'"
return 1
elif [[ $f != *.fs ]] && ! diff -a --strip-trailing-cr .github/license-header.txt <(head -$NLINES "$f") >/dev/null; then
echo "check-license-headers: error: '$f' does not have required license header, see 'diff -u .github/license-header.txt <(head -$NLINES $f)'"
elif [[ $f != *.fs ]] && ! diff -a --strip-trailing-cr .github/license-header.txt <(head -$NLINES_CS "$f") >/dev/null; then
echo "check-license-headers: error: '$f' does not have required license header, see 'diff -u .github/license-header.txt <(head -$NLINES_CS $f)'"
return 1
else
return 0
Expand Down
21 changes: 0 additions & 21 deletions .github/license-header-fs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,3 @@
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
// Modifications Copyright OpenSearch Contributors. See
// GitHub history for details.
//
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you 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.
//
20 changes: 0 additions & 20 deletions .github/license-header.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,4 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you 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.
*/
3 changes: 2 additions & 1 deletion src/ApiGenerator/CodeTemplatePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
3 changes: 2 additions & 1 deletion src/ApiGenerator/Configuration/CodeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
3 changes: 2 additions & 1 deletion src/ApiGenerator/Configuration/GeneratorLocations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
3 changes: 2 additions & 1 deletion src/ApiGenerator/Configuration/Overrides/GlobalOverrides.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
3 changes: 2 additions & 1 deletion src/ApiGenerator/Configuration/ViewLocations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
3 changes: 2 additions & 1 deletion src/ApiGenerator/Domain/ApiQueryParametersPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
3 changes: 2 additions & 1 deletion src/ApiGenerator/Domain/Code/CsharpNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*
Expand Down
Loading

0 comments on commit 6703cd4

Please sign in to comment.