Skip to content

Commit

Permalink
DAOS-623 ci: Add copyright for Google (#15713)
Browse files Browse the repository at this point in the history
Modifies the githook to automatically use google copyright for Googlers

Signed-off-by: Jeff Olivier <[email protected]>
  • Loading branch information
jolivier23 authored Jan 10, 2025
1 parent ece5b0a commit 087ecb6
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions utils/cq/check_update_copyright.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Copyright 2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
# Copyright 2025 Google LLC
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand All @@ -28,9 +29,11 @@ cd "$PARENT_DIR"/../../


regex_intel='(^[[:blank:]]*[\*/]*.*)((Copyright[[:blank:]]*)([0-9]{4})(-([0-9]{4}))?)([[:blank:]]*(Intel.*$))'
# shortname_intel="Intel Corporation."
shortname_intel="Intel Corporation."
regex_hpe='(^[[:blank:]]*[\*/]*.*)((Copyright[[:blank:]]*)([0-9]{4})(-([0-9]{4}))?)([[:blank:]]*(Hewlett Packard Enterprise Development LP.*$))'
shortname_hpe="Hewlett Packard Enterprise Development LP"
regex_google='(^[[:blank:]]*[\*/]*.*)((Copyright[[:blank:]]*)([0-9]{4})(-([0-9]{4}))?)([[:blank:]]*(Google LLC.*$))'
shortname_google="Google LLC"
year=$(date +%Y)
errors=0
targets=(
Expand Down Expand Up @@ -86,26 +89,31 @@ function git_add() {
# See below example to toggle copyright regex based on user
regex_user="$regex_hpe"
shortname_user="$shortname_hpe"
# if [[ "$mode" == "githook" ]]; then
# # Extract domain from configured email
# user_domain="$(git config user.email | sed -n 's/^.*@\([-0-9a-zA-Z]*\).*/\1/p')"
# else
# # Extract domain from the first Signed-off-by
# user_domain="$(git log -1 | grep 'Signed-off-by' | head -n 1 | sed -n 's/^.*@\([-0-9a-zA-Z]*\).*/\1/p')"
# fi
# case "$user_domain" in
# "hpe")
# regex_user="$regex_hpe"
# shortname_user="$shortname_hpe"
# ;;
# "intel")
# regex_user="$regex_intel"
# shortname_user="$shortname_intel"
# ;;
# *)
# echo " Unsupported email domain: $user_domain"
# exit 1
# esac
if [[ "$mode" == "githook" ]]; then
# Extract domain from configured email
user_domain="$(git config user.email | sed -n 's/^.*@\([-0-9a-zA-Z]*\).*/\1/p')"
else
# Extract domain from the first Signed-off-by
user_domain="$(git log -1 | grep 'Signed-off-by' | head -n 1 | sed -n 's/^.*@\([-0-9a-zA-Z]*\).*/\1/p')"
fi
case "$user_domain" in
"hpe")
regex_user="$regex_hpe"
shortname_user="$shortname_hpe"
;;
"intel")
regex_user="$regex_intel"
shortname_user="$shortname_intel"
;;
"google")
regex_user="$regex_google"
shortname_user="$shortname_google"
;;
*)
regex_user="$regex_hpe"
shortname_user="$shortname_hpe"
;;
esac

# Generate list of all copyright regex except the user's domain.
# Used to add a new copyright header to files.
Expand Down

0 comments on commit 087ecb6

Please sign in to comment.