From 2af1cd697553cfd05de370538d9b37ab9d056dd9 Mon Sep 17 00:00:00 2001 From: Dalton Bohning Date: Thu, 19 Dec 2024 14:39:41 +0000 Subject: [PATCH 1/6] DAOS-16898 cq: support user bash in githooks Replace hardcoded /bin/bash with /usr/bin/env bash in the githook scripts, for the case where /bin/bash does not support newer features like, e.g., mapfile. Skip-test: true Skip-tests: true SKip-unit-tests: true Skip-nlt: true Required-githooks: true Signed-off-by: Dalton Bohning --- utils/githooks/find_base.sh | 2 +- utils/githooks/git-version.sh | 2 +- utils/githooks/hook_base.sh | 2 +- utils/githooks/pre-commit | 2 +- utils/githooks/pre-commit.d/10-update-copyright.sh | 2 +- utils/githooks/pre-commit.d/20-codespell.sh | 2 +- utils/githooks/pre-commit.d/30-Jenkinsfile.sh | 2 +- utils/githooks/pre-commit.d/40-yamllint.sh | 2 +- utils/githooks/pre-commit.d/50-clang-format.sh | 2 +- utils/githooks/pre-commit.d/60-gofmt.sh | 2 +- utils/githooks/pre-commit.d/70-isort.sh | 2 +- utils/githooks/pre-commit.d/71-flake.sh | 2 +- utils/githooks/pre-commit.d/72-pylint.sh | 2 +- utils/githooks/pre-commit.d/73-ftest.sh | 2 +- utils/githooks/prepare-commit-msg | 2 +- utils/rpms/packaging/get_release_branch | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/utils/githooks/find_base.sh b/utils/githooks/find_base.sh index 292a02f66e7..1ea1e6ffe24 100644 --- a/utils/githooks/find_base.sh +++ b/utils/githooks/find_base.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # /* # * (C) Copyright 2024 Intel Corporation. # * diff --git a/utils/githooks/git-version.sh b/utils/githooks/git-version.sh index 29e141f40c8..99105038961 100644 --- a/utils/githooks/git-version.sh +++ b/utils/githooks/git-version.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash VERSION=$(git --version | sed -ne 's/^[^0-9]*\([[0-9\.]*\).*/\1/p') if [ -z "$VERSION" ]; then diff --git a/utils/githooks/hook_base.sh b/utils/githooks/hook_base.sh index 3def155df68..4287e3dc597 100755 --- a/utils/githooks/hook_base.sh +++ b/utils/githooks/hook_base.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2024 Intel Corporation. # diff --git a/utils/githooks/pre-commit b/utils/githooks/pre-commit index cab804423fc..d49ec08bd39 100755 --- a/utils/githooks/pre-commit +++ b/utils/githooks/pre-commit @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eu . utils/githooks/hook_base.sh diff --git a/utils/githooks/pre-commit.d/10-update-copyright.sh b/utils/githooks/pre-commit.d/10-update-copyright.sh index b88cce8e634..a538ee9fc86 100755 --- a/utils/githooks/pre-commit.d/10-update-copyright.sh +++ b/utils/githooks/pre-commit.d/10-update-copyright.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. # diff --git a/utils/githooks/pre-commit.d/20-codespell.sh b/utils/githooks/pre-commit.d/20-codespell.sh index 570a85c1d6e..9a7e620ad29 100755 --- a/utils/githooks/pre-commit.d/20-codespell.sh +++ b/utils/githooks/pre-commit.d/20-codespell.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2024 Intel Corporation. # diff --git a/utils/githooks/pre-commit.d/30-Jenkinsfile.sh b/utils/githooks/pre-commit.d/30-Jenkinsfile.sh index c69f08ffac5..8980bde1266 100755 --- a/utils/githooks/pre-commit.d/30-Jenkinsfile.sh +++ b/utils/githooks/pre-commit.d/30-Jenkinsfile.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2023-2024 Intel Corporation. # diff --git a/utils/githooks/pre-commit.d/40-yamllint.sh b/utils/githooks/pre-commit.d/40-yamllint.sh index 60b62fe86a8..8a417ce0d48 100755 --- a/utils/githooks/pre-commit.d/40-yamllint.sh +++ b/utils/githooks/pre-commit.d/40-yamllint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. # diff --git a/utils/githooks/pre-commit.d/50-clang-format.sh b/utils/githooks/pre-commit.d/50-clang-format.sh index 82b725d2624..09b011a1f00 100755 --- a/utils/githooks/pre-commit.d/50-clang-format.sh +++ b/utils/githooks/pre-commit.d/50-clang-format.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. # diff --git a/utils/githooks/pre-commit.d/60-gofmt.sh b/utils/githooks/pre-commit.d/60-gofmt.sh index 0a702948786..0dd2279472c 100755 --- a/utils/githooks/pre-commit.d/60-gofmt.sh +++ b/utils/githooks/pre-commit.d/60-gofmt.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. # diff --git a/utils/githooks/pre-commit.d/70-isort.sh b/utils/githooks/pre-commit.d/70-isort.sh index 9b3d9fc445a..c83489b0e07 100755 --- a/utils/githooks/pre-commit.d/70-isort.sh +++ b/utils/githooks/pre-commit.d/70-isort.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2023-2024 Intel Corporation. # diff --git a/utils/githooks/pre-commit.d/71-flake.sh b/utils/githooks/pre-commit.d/71-flake.sh index 082e0f863d8..57d66557b68 100755 --- a/utils/githooks/pre-commit.d/71-flake.sh +++ b/utils/githooks/pre-commit.d/71-flake.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. # diff --git a/utils/githooks/pre-commit.d/72-pylint.sh b/utils/githooks/pre-commit.d/72-pylint.sh index 4bff2456a66..32f05721c10 100755 --- a/utils/githooks/pre-commit.d/72-pylint.sh +++ b/utils/githooks/pre-commit.d/72-pylint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. # diff --git a/utils/githooks/pre-commit.d/73-ftest.sh b/utils/githooks/pre-commit.d/73-ftest.sh index 9eaf4e8253b..4135b02f5ed 100755 --- a/utils/githooks/pre-commit.d/73-ftest.sh +++ b/utils/githooks/pre-commit.d/73-ftest.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2024 Intel Corporation. # diff --git a/utils/githooks/prepare-commit-msg b/utils/githooks/prepare-commit-msg index 59aec7c8578..1381c80102a 100755 --- a/utils/githooks/prepare-commit-msg +++ b/utils/githooks/prepare-commit-msg @@ -1,3 +1,3 @@ -#!/bin/bash +#!/usr/bin/env bash . utils/githooks/hook_base.sh diff --git a/utils/rpms/packaging/get_release_branch b/utils/rpms/packaging/get_release_branch index e017cca2071..3648ccde35d 100755 --- a/utils/rpms/packaging/get_release_branch +++ b/utils/rpms/packaging/get_release_branch @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # find the base branch of the current branch # base branches can be master, release/2.4+, release/3+ From d8bb6d126c3a97443b1ffa6c79ca0ccf315edbf9 Mon Sep 17 00:00:00 2001 From: Dalton Bohning Date: Thu, 19 Dec 2024 19:07:13 +0000 Subject: [PATCH 2/6] fix unbound variable Skip-test: true Skip-tests: true Skip-unit-tests: true Skip-nlt: true Required-githooks: true Signed-off-by: Dalton Bohning --- utils/githooks/hook_base.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/githooks/hook_base.sh b/utils/githooks/hook_base.sh index 4287e3dc597..32f776fbeb4 100755 --- a/utils/githooks/hook_base.sh +++ b/utils/githooks/hook_base.sh @@ -31,6 +31,7 @@ export -f _git_diff_cached_files hook=${0##*/} rm -f ".${hook}" +skip_list=() IFS=', ' read -r -a skip_list <<< "${DAOS_GITHOOK_SKIP:-}" run-parts() { From 68ad6aea4695fa8262a479532055e07751cd3c61 Mon Sep 17 00:00:00 2001 From: Dalton Bohning Date: Fri, 20 Dec 2024 19:30:18 +0000 Subject: [PATCH 3/6] missed one Skip-test: true Skip-tests: true Skip-unit-tests: true Skip-nlt: true Required-githooks: true Signed-off-by: Dalton Bohning --- utils/cq/check_update_copyright.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/cq/check_update_copyright.sh b/utils/cq/check_update_copyright.sh index 5bb4016915f..9a651bff591 100755 --- a/utils/cq/check_update_copyright.sh +++ b/utils/cq/check_update_copyright.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Copyright 2024 Intel Corporation. # From d0aeaad41aff85496b4aa4f67017ab31fcf80045 Mon Sep 17 00:00:00 2001 From: Dalton Bohning Date: Thu, 9 Jan 2025 15:25:48 +0000 Subject: [PATCH 4/6] replace mapfile with loop in get_release_branch Skip-test: true Skip-tests: true Skip-unit-tests: true Skip-nlt: true Signed-off-by: Dalton Bohning --- utils/rpms/packaging/get_release_branch | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils/rpms/packaging/get_release_branch b/utils/rpms/packaging/get_release_branch index 3648ccde35d..6b83aced777 100755 --- a/utils/rpms/packaging/get_release_branch +++ b/utils/rpms/packaging/get_release_branch @@ -6,9 +6,11 @@ set -eu -o pipefail IFS=' ' read -r -a add_bases <<< "${1:-}" origin="${ORIGIN:-origin}" -mapfile -t all_bases < <(echo "master" - git branch -r | sed -ne "/^ $origin\\/release\\/\(2.[4-9]\|[3-9]\)/s/^ $origin\\///p") -all_bases+=("${add_bases[@]}") +all_bases=() +while IFS= read -r base; do + all_bases+=("$base") +done < <(echo "master" + git branch -r | sed -ne "/^ $origin\\/release\\/\(2.[4-9]\|[3-9]\)/s/^ $origin\\///p") TARGET="master" min_diff=-1 for base in "${all_bases[@]}"; do From c3b67e1e62662776c8a6fb40627fcea79bff342d Mon Sep 17 00:00:00 2001 From: Dalton Bohning Date: Thu, 9 Jan 2025 15:45:12 +0000 Subject: [PATCH 5/6] copyright Skip-test: true Skip-tests: true Skip-unit-tests: true Skip-nlt: true Signed-off-by: Dalton Bohning --- utils/githooks/find_base.sh | 1 + utils/githooks/hook_base.sh | 1 + utils/githooks/pre-commit.d/10-update-copyright.sh | 1 + utils/githooks/pre-commit.d/20-codespell.sh | 1 + utils/githooks/pre-commit.d/30-Jenkinsfile.sh | 1 + utils/githooks/pre-commit.d/40-yamllint.sh | 1 + utils/githooks/pre-commit.d/50-clang-format.sh | 1 + utils/githooks/pre-commit.d/60-gofmt.sh | 1 + utils/githooks/pre-commit.d/70-isort.sh | 1 + utils/githooks/pre-commit.d/71-flake.sh | 1 + utils/githooks/pre-commit.d/72-pylint.sh | 1 + utils/githooks/pre-commit.d/73-ftest.sh | 1 + utils/rpms/packaging/get_release_branch | 6 +++++- 13 files changed, 17 insertions(+), 1 deletion(-) diff --git a/utils/githooks/find_base.sh b/utils/githooks/find_base.sh index 1ea1e6ffe24..b812d28a783 100644 --- a/utils/githooks/find_base.sh +++ b/utils/githooks/find_base.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # /* # * (C) Copyright 2024 Intel Corporation. +# * (C) Copyright 2025 Hewlett Packard Enterprise Development LP # * # * SPDX-License-Identifier: BSD-2-Clause-Patent # */ diff --git a/utils/githooks/hook_base.sh b/utils/githooks/hook_base.sh index 9bb6e501382..223070f2ea9 100755 --- a/utils/githooks/hook_base.sh +++ b/utils/githooks/hook_base.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/githooks/pre-commit.d/10-update-copyright.sh b/utils/githooks/pre-commit.d/10-update-copyright.sh index a538ee9fc86..e962e000168 100755 --- a/utils/githooks/pre-commit.d/10-update-copyright.sh +++ b/utils/githooks/pre-commit.d/10-update-copyright.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/githooks/pre-commit.d/20-codespell.sh b/utils/githooks/pre-commit.d/20-codespell.sh index d4722353e2a..dcc7bdb6380 100755 --- a/utils/githooks/pre-commit.d/20-codespell.sh +++ b/utils/githooks/pre-commit.d/20-codespell.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/githooks/pre-commit.d/30-Jenkinsfile.sh b/utils/githooks/pre-commit.d/30-Jenkinsfile.sh index 8980bde1266..f1f44d80989 100755 --- a/utils/githooks/pre-commit.d/30-Jenkinsfile.sh +++ b/utils/githooks/pre-commit.d/30-Jenkinsfile.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2023-2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/githooks/pre-commit.d/40-yamllint.sh b/utils/githooks/pre-commit.d/40-yamllint.sh index 8a417ce0d48..c080edc7447 100755 --- a/utils/githooks/pre-commit.d/40-yamllint.sh +++ b/utils/githooks/pre-commit.d/40-yamllint.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/githooks/pre-commit.d/50-clang-format.sh b/utils/githooks/pre-commit.d/50-clang-format.sh index 09b011a1f00..1c25256794a 100755 --- a/utils/githooks/pre-commit.d/50-clang-format.sh +++ b/utils/githooks/pre-commit.d/50-clang-format.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/githooks/pre-commit.d/60-gofmt.sh b/utils/githooks/pre-commit.d/60-gofmt.sh index 0dd2279472c..c8cad14f530 100755 --- a/utils/githooks/pre-commit.d/60-gofmt.sh +++ b/utils/githooks/pre-commit.d/60-gofmt.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/githooks/pre-commit.d/70-isort.sh b/utils/githooks/pre-commit.d/70-isort.sh index c83489b0e07..eb511f61013 100755 --- a/utils/githooks/pre-commit.d/70-isort.sh +++ b/utils/githooks/pre-commit.d/70-isort.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2023-2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/githooks/pre-commit.d/71-flake.sh b/utils/githooks/pre-commit.d/71-flake.sh index 57d66557b68..cf00e8e6388 100755 --- a/utils/githooks/pre-commit.d/71-flake.sh +++ b/utils/githooks/pre-commit.d/71-flake.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/githooks/pre-commit.d/72-pylint.sh b/utils/githooks/pre-commit.d/72-pylint.sh index 32f05721c10..047de5ba974 100755 --- a/utils/githooks/pre-commit.d/72-pylint.sh +++ b/utils/githooks/pre-commit.d/72-pylint.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2022-2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/githooks/pre-commit.d/73-ftest.sh b/utils/githooks/pre-commit.d/73-ftest.sh index 4135b02f5ed..0fc7248f08e 100755 --- a/utils/githooks/pre-commit.d/73-ftest.sh +++ b/utils/githooks/pre-commit.d/73-ftest.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # # Copyright 2024 Intel Corporation. +# Copyright 2025 Hewlett Packard Enterprise Development LP # # SPDX-License-Identifier: BSD-2-Clause-Patent # diff --git a/utils/rpms/packaging/get_release_branch b/utils/rpms/packaging/get_release_branch index 6b83aced777..6ce032d1d27 100755 --- a/utils/rpms/packaging/get_release_branch +++ b/utils/rpms/packaging/get_release_branch @@ -1,5 +1,9 @@ #!/usr/bin/env bash - +# +# Copyright 2025 Hewlett Packard Enterprise Development LP +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# # find the base branch of the current branch # base branches can be master, release/2.4+, release/3+ # or optionally branches passed into $1 From 4dc4cc37edc809508219a7feb5976e1ac9069898 Mon Sep 17 00:00:00 2001 From: Dalton Bohning Date: Fri, 10 Jan 2025 17:46:52 +0000 Subject: [PATCH 6/6] proper fix unbound per liw Skip-test: true Skip-tests: true Skip-unit-tests: true Skip-nlt: true Signed-off-by: Dalton Bohning --- utils/githooks/hook_base.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/githooks/hook_base.sh b/utils/githooks/hook_base.sh index 223070f2ea9..d9478d49ea7 100755 --- a/utils/githooks/hook_base.sh +++ b/utils/githooks/hook_base.sh @@ -32,7 +32,6 @@ export -f _git_diff_cached_files hook=${0##*/} rm -f ".${hook}" -skip_list=() IFS=', ' read -r -a skip_list <<< "${DAOS_GITHOOK_SKIP:-}" run-parts() { @@ -43,7 +42,7 @@ run-parts() { # don't run vim .swp files [ "${i%.sw?}" != "${i}" ] && continue skip_item=false - for skip in "${skip_list[@]}"; do + for skip in "${skip_list[@]:-}"; do if [[ "${i}" =~ ${skip} ]]; then skip_item=true echo "Skipping ${i}"