Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backends/arm/scripts/setup-dev-env.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
# Copyright 2025 Arm Limited and/or its affiliates.
# Copyright 2025-2026 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
ln -s "$(realpath "$git_dir/../backends/arm/scripts/pre-push")" "$(realpath "$git_dir")/hooks"
ln -s "$(realpath "$git_dir/../backends/arm/scripts/pre-commit")" "$(realpath "$git_dir")/hooks"
Comment on lines +8 to +9
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ln -s SOURCE DESTDIR only works as intended if DESTDIR already exists and is a directory; otherwise it will create a symlink named hooks (or fail), which is not what you want for Git hooks. Consider linking to explicit destination filenames (e.g., .../hooks/pre-push and .../hooks/pre-commit) and making the script idempotent by using -f (or removing existing hooks first).

Suggested change
ln -s "$(realpath "$git_dir/../backends/arm/scripts/pre-push")" "$(realpath "$git_dir")/hooks"
ln -s "$(realpath "$git_dir/../backends/arm/scripts/pre-commit")" "$(realpath "$git_dir")/hooks"
hooks_dir="$(realpath "$git_dir")/hooks"
mkdir -p "$hooks_dir"
ln -sf "$(realpath "$git_dir/../backends/arm/scripts/pre-push")" "$hooks_dir/pre-push"
ln -sf "$(realpath "$git_dir/../backends/arm/scripts/pre-commit")" "$hooks_dir/pre-commit"

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +9
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using realpath forces absolute symlink targets, which can break if the repo is moved (e.g., relocating a workspace). A relative symlink (computed from the hooks directory to backends/arm/scripts/...) typically preserves the 'always use latest checkout' behavior while remaining robust to path changes; also note realpath isn’t universally available in minimal environments.

Suggested change
ln -s "$(realpath "$git_dir/../backends/arm/scripts/pre-push")" "$(realpath "$git_dir")/hooks"
ln -s "$(realpath "$git_dir/../backends/arm/scripts/pre-commit")" "$(realpath "$git_dir")/hooks"
mkdir -p "$git_dir/hooks"
(
cd "$git_dir/hooks" || exit 1
ln -s "../../backends/arm/scripts/pre-push" pre-push
ln -s "../../backends/arm/scripts/pre-commit" pre-commit
)

Copilot uses AI. Check for mistakes.
Loading