1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 12:06:01 +01:00

shellcheck fix: tests/functional/fetchGitRefs.sh

This commit is contained in:
Farid Zakaria 2025-09-25 10:46:34 -07:00
parent 32e1b5209b
commit 1619409bf2
2 changed files with 4 additions and 4 deletions

View file

@ -107,7 +107,6 @@
excludes = [ excludes = [
# We haven't linted these files yet # We haven't linted these files yet
''^tests/functional/dump-db\.sh$'' ''^tests/functional/dump-db\.sh$''
''^tests/functional/fetchGitRefs\.sh$''
''^tests/functional/fetchGitSubmodules\.sh$'' ''^tests/functional/fetchGitSubmodules\.sh$''
''^tests/functional/fetchGitVerification\.sh$'' ''^tests/functional/fetchGitVerification\.sh$''
''^tests/functional/fetchMercurial\.sh$'' ''^tests/functional/fetchMercurial\.sh$''

View file

@ -38,16 +38,16 @@ path=$(nix eval --raw --impure --expr "(builtins.fetchGit { url = $repo; ref = \
# 10. They cannot contain a \. # 10. They cannot contain a \.
valid_ref() { valid_ref() {
{ set +x; printf >&2 '\n>>>>>>>>>> valid_ref %s\b <<<<<<<<<<\n' $(printf %s "$1" | sed -n -e l); set -x; } { set +x; printf >&2 '\n>>>>>>>>>> valid_ref %s\b <<<<<<<<<<\n' "$(printf %s "$1" | sed -n -e l)"; set -x; }
git check-ref-format --branch "$1" >/dev/null git check-ref-format --branch "$1" >/dev/null
git -C "$repo" branch "$1" master >/dev/null git -C "$repo" branch "$1" master >/dev/null
path1=$(nix eval --raw --impure --expr "(builtins.fetchGit { url = $repo; ref = ''$1''; }).outPath") path1=$(nix eval --raw --impure --expr "(builtins.fetchGit { url = $repo; ref = ''$1''; }).outPath")
[[ $path1 = $path ]] [[ $path1 = "$path" ]]
git -C "$repo" branch -D "$1" >/dev/null git -C "$repo" branch -D "$1" >/dev/null
} }
invalid_ref() { invalid_ref() {
{ set +x; printf >&2 '\n>>>>>>>>>> invalid_ref %s\b <<<<<<<<<<\n' $(printf %s "$1" | sed -n -e l); set -x; } { set +x; printf >&2 '\n>>>>>>>>>> invalid_ref %s\b <<<<<<<<<<\n' "$(printf %s "$1" | sed -n -e l)"; set -x; }
# special case for a sole @: # special case for a sole @:
# --branch @ will try to interpret @ as a branch reference and not fail. Thus we need --allow-onelevel # --branch @ will try to interpret @ as a branch reference and not fail. Thus we need --allow-onelevel
if [ "$1" = "@" ]; then if [ "$1" = "@" ]; then
@ -68,6 +68,7 @@ valid_ref 'heads/foo@bar'
valid_ref "$(printf 'heads/fu\303\237')" valid_ref "$(printf 'heads/fu\303\237')"
valid_ref 'foo-bar-baz' valid_ref 'foo-bar-baz'
valid_ref 'branch#' valid_ref 'branch#'
# shellcheck disable=SC2016
valid_ref '$1' valid_ref '$1'
valid_ref 'foo.locke' valid_ref 'foo.locke'