diff --git a/backends/arm/scripts/pre-commit b/backends/arm/scripts/pre-commit new file mode 100755 index 00000000000..2000585f930 --- /dev/null +++ b/backends/arm/scripts/pre-commit @@ -0,0 +1,13 @@ +#!/bin/bash +# Copyright 2025 Arm Limited and/or its affiliates. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# Check 1: If commit header contains WIP, everything is ok +git rev-list --format=%s --max-count=1 HEAD | grep -q WIP && exit 0 + +# Check 2: lintunner on latest patch. +lintrunner -a --revision 'HEAD^' --skip MYPY +commit_files=$(git diff-tree --no-commit-id --name-only --diff-filter=M HEAD -r) +git add $commit_files || true \ No newline at end of file diff --git a/backends/arm/scripts/pre-push b/backends/arm/scripts/pre-push new file mode 100755 index 00000000000..c51138b8ec7 --- /dev/null +++ b/backends/arm/scripts/pre-push @@ -0,0 +1,45 @@ +#!/bin/bash +# Copyright 2025 Arm Limited and/or its affiliates. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +# Check 1: If commit header contains WIP, everything is ok +git rev-list --format=%s --max-count=1 HEAD | grep -q WIP && exit 0 + +# Check 2: lintunner on latest patches. +lintrunner --revision 'HEAD^' +if [[ $? != 0 ]] + then + echo "Failed linting" + exit 1 +fi + +# Check 3: License headers +# We do a simple check of if all committed headers contain "$current_year Arm". +# This does not guarantee OK in ci but should be ok most of the time. + +current_year=$(date +%Y) +failed_license_check=false +commit_files=$(git diff-tree --no-commit-id --name-only --diff-filter=ACMR HEAD -r) + + +for commited_file in $commit_files; do + head $commited_file | grep -q "$current_year Arm" + if [[ $? != 0 ]] + then + echo "Header in $commited_file did not contain '$current_year Arm'" + failed_license_check=true + else + echo "$commited_file passed license check" + fi +done + +if [[ $failed_license_check == true ]] + then + exit 1 + else + echo "Passed simple license check" +fi + +exit 0 diff --git a/backends/arm/scripts/setup-dev-env.sh b/backends/arm/scripts/setup-dev-env.sh new file mode 100755 index 00000000000..b8c9b3b44cd --- /dev/null +++ b/backends/arm/scripts/setup-dev-env.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Copyright 2025 Arm Limited and/or its affiliates. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +git_dir=$(git rev-parse --git-dir) +ln $git_dir/../backends/arm/scripts/pre-push $git_dir/hooks +ln $git_dir/../backends/arm/scripts/pre-commit $git_dir/hooks \ No newline at end of file