I am creating a git hook to check new local branch name against all remote branches for matching names and then check case differences. I have not got compare to work using basename to trim the branch.
Just running echo "$(basename $branch)"
in the loop:
branches=()
eval "$(git for-each-ref --shell --format='branches+=(%(refname))' refs/remotes/origin/)"
for branch in "${branches[@]}"; do
echo "$(basename $branch)"
done
works fine and returns the correct branch names stripped down from refs/remotes/origin/master to just master etc.
integration_2021R1
master
net-standard-upgrade
net5-stable
netstandard-actions
platform
stable
stable_15.2_hfr7
stable_2020R1
stable_2021R1
but in the comparison:
if ["$local_branch_name" == "$(basename $branch)"]; then
echo "branch match"
fi
all I get is command not found.
I even tried to change the echo to a variable assign but that also causes command not found.
var = "$(basename $branch)"
output:
GitHooks/pre-commit: line 19: var: command not found
GitHooks/pre-commit: line 19: var: command not found
GitHooks/pre-commit: line 19: var: command not found
GitHooks/pre-commit: line 19: var: command not found
GitHooks/pre-commit: line 19: var: command not found
GitHooks/pre-commit: line 19: var: command not found
GitHooks/pre-commit: line 19: var: command not found
GitHooks/pre-commit: line 19: var: command not found
GitHooks/pre-commit: line 19: var: command not found
GitHooks/pre-commit: line 19: var: command not found
for all branches.