Skip to content

Commit

Permalink
Fix copyright header prepend to work on mac (#6)
Browse files Browse the repository at this point in the history
* Fix update script so it also works on mac.

* Update scripts/update.sh

Co-authored-by: Stanislav German-Evtushenko (SBI) <[email protected]>

* Fix copyright header handling (did not work on mac)

---------

Co-authored-by: Stanislav German-Evtushenko (SBI) <[email protected]>
  • Loading branch information
ray-roestenburg-da and stas-sbi authored Jul 1, 2024
1 parent 311a0b7 commit 32d3186
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ pkgs=$(ls "$CN_REPO_ROOT/daml" | grep -v '^\(dars\|splitwell\)')

copy_daml $CN_REPO_ROOT/daml daml

COPYRIGHT_ESCAPED='-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and\/or its affiliates\. All rights reserved\.\
-- SPDX-License-Identifier: Apache-2\.0\
\
'
prepend_copyright() {
read -r -d '' COPYRIGHT_ESCAPED << 'EOF'
-- Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
EOF
file="$1"
first_line=$(head -n 1 "$file")
if [[ ! "$first_line" =~ ^--\ Copyright ]]; then
echo -e "$COPYRIGHT_ESCAPED\n" | cat - "$file" > "$file.tmp" && mv "$file.tmp" "$file"
fi
}
export -f prepend_copyright

find daml -type f -name \*.daml -exec bash -c 'grep -q -e "-- Copyright" "$0" || sed -i "1s/^/$1/" $0' '{}' "$COPYRIGHT_ESCAPED" \;
find daml -type f -name \*.daml -exec bash -c 'prepend_copyright "$0"' {} \;

copy_daml daml $SPLICE_REPO_ROOT/daml

0 comments on commit 32d3186

Please sign in to comment.