Also add license comments in YAML, JS, Go & Java source files

This commit is contained in:
Troy McConaghy 2018-08-09 15:21:42 +02:00
parent 4d9dba9a03
commit 4dc60d13ce

View File

@ -14,8 +14,8 @@
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'
# All files named *.py or *.sh or *.bash # All files named *.py or *.sh or *.bash or *.yaml or *.yml
find . -type f \( -name "*.py" -o -name "*.sh" -o -name "*.bash" \) | while read fname; do find . -type f \( -name "*.py" -o -name "*.sh" -o -name "*.bash" -o -name "*.yaml" -o -name "*.yml" \) | while read fname; do
if [ "`head -c 2 $fname`" = "#!" ]; then if [ "`head -c 2 $fname`" = "#!" ]; then
# The file '$fname' begins with a hashbang so add the SPDX lines on lines 2+ # The file '$fname' begins with a hashbang so add the SPDX lines on lines 2+
sed -i '2s/^/# Copyright BigchainDB GmbH and BigchainDB contributors\n# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)\n# Code is Apache-2.0 and docs are CC-BY-4.0\n\n/' $fname sed -i '2s/^/# Copyright BigchainDB GmbH and BigchainDB contributors\n# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)\n# Code is Apache-2.0 and docs are CC-BY-4.0\n\n/' $fname
@ -25,6 +25,28 @@ find . -type f \( -name "*.py" -o -name "*.sh" -o -name "*.bash" \) | while read
fi fi
done done
# All files named *.js or *.go (JavaScript, Node.js or Golang)
find . -type f \( -name "*.js" -o -name "*.go" \) | while read fname; do
if [ "`head -c 2 $fname`" = "#!" ]; then
# The file '$fname' begins with a hashbang so add the SPDX lines on lines 2+
sed -i '2s;^;// Copyright BigchainDB GmbH and BigchainDB contributors\n// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)\n// Code is Apache-2.0 and docs are CC-BY-4.0\n\n;' $fname
else
# add the SPDX lines on lines 1+
sed -i '1s;^;// Copyright BigchainDB GmbH and BigchainDB contributors\n// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)\n// Code is Apache-2.0 and docs are CC-BY-4.0\n\n;' $fname
fi
done
# All files named *.java
find . -type f -name "*.java" | while read fname; do
if [ "`head -c 2 $fname`" = "#!" ]; then
# The file '$fname' begins with a hashbang so add the SPDX lines on lines 2+
sed -i '2s;^;/*\n * Copyright BigchainDB GmbH and BigchainDB contributors\n * SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)\n * Code is Apache-2.0 and docs are CC-BY-4.0\n */\n;' $fname
else
# add the SPDX lines on lines 1+
sed -i '1s;^;/*\n * Copyright BigchainDB GmbH and BigchainDB contributors\n * SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)\n * Code is Apache-2.0 and docs are CC-BY-4.0\n */\n;' $fname
fi
done
# All files named *.md (Markdown). # All files named *.md (Markdown).
find . -type f -name "*.md" | while read fname; do find . -type f -name "*.md" | while read fname; do
sed -i '1s;^;<!---\nCopyright BigchainDB GmbH and BigchainDB contributors\nSPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)\nCode is Apache-2.0 and docs are CC-BY-4.0\n--->\n\n;' $fname sed -i '1s;^;<!---\nCopyright BigchainDB GmbH and BigchainDB contributors\nSPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)\nCode is Apache-2.0 and docs are CC-BY-4.0\n--->\n\n;' $fname