Skip to content

Commit

Permalink
CI: embed script into make
Browse files Browse the repository at this point in the history
  • Loading branch information
tarassh committed Aug 21, 2024
1 parent 47e714b commit 5aa7b99
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,24 @@ command = "cargo"
args = ["clippy", "--", "--deny", "warnings"]

[tasks.header-add]
script = { file = "./scripts/add_header_if_missing.sh" }
script = [
"if [ \"$#\" -lt 2 ]; then",
" echo 'Usage: $0 <header-file> <file-pattern>'",
" exit 1",
"fi",
"HEADER_FILE=\"$1\"",
"FILE_PATTERN=\"$2\"",
"LICENSE_HEADER=$(cat \"$HEADER_FILE\")",
"shopt -s globstar",
"for file in $FILE_PATTERN; do",
" if [[ -f \"$file\" && \"$file\" == *.rs ]]; then",
" if ! grep -q 'Copyright 2024, Horizen Labs, Inc.' \"$file\"; then",
" echo 'Adding license header to $file'",
" echo -e \"$LICENSE_HEADER\\n$(cat $file)\" > \"$file\"",
" fi",
" fi",
"done"
]
args = ["HEADER-APACHE2", "./!(target)/**/*.rs"]

[tasks.header-check]
Expand Down

0 comments on commit 5aa7b99

Please sign in to comment.