istio.io/istio@v0.0.0-20240520182934-d79c90f27776/common/scripts/fix_copyright_banner.sh (about)

     1  #!/bin/bash
     2  
     3  # WARNING: DO NOT EDIT, THIS FILE IS PROBABLY A COPY
     4  #
     5  # The original version of this file is located in the https://github.com/istio/common-files repo.
     6  # If you're looking at this file in a different repo and want to make a change, please go to the
     7  # common-files repo, make the change there and check it in. Then come back to this repo and run
     8  # "make update-common".
     9  
    10  # Copyright Istio Authors
    11  #
    12  # Licensed under the Apache License, Version 2.0 (the "License");
    13  # you may not use this file except in compliance with the License.
    14  # You may obtain a copy of the License at
    15  #
    16  #    http://www.apache.org/licenses/LICENSE-2.0
    17  #
    18  # Unless required by applicable law or agreed to in writing, software
    19  # distributed under the License is distributed on an "AS IS" BASIS,
    20  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    21  # See the License for the specific language governing permissions and
    22  # limitations under the License.
    23  
    24  set -e
    25  
    26  WD=$(dirname "$0")
    27  WD=$(cd "$WD"; pwd)
    28  
    29  for fn in "$@"; do
    30    if ! grep -L -q -e "Apache License, Version 2" -e "Copyright" "${fn}"; then
    31      if [[ "${fn}" == *.go || "${fn}" == *.rs ]]; then
    32        newfile=$(cat "${WD}/copyright-banner-go.txt" "${fn}")
    33        echo "${newfile}" > "${fn}"
    34        echo "Fixing license: ${fn}"
    35      else
    36        echo "Cannot fix license: ${fn}. Unknown file type"
    37      fi
    38    fi
    39  done