Skip to content

Commit

Permalink
DAOS-16898 cq: support user bash in githooks (#15648)
Browse files Browse the repository at this point in the history
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.

replace mapfile with loop in get_release_branch

Signed-off-by: Dalton Bohning <[email protected]>
  • Loading branch information
daltonbohning authored Jan 24, 2025
1 parent 5f61167 commit 17c86a1
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 23 deletions.
2 changes: 1 addition & 1 deletion utils/cq/check_update_copyright.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
Expand Down
3 changes: 2 additions & 1 deletion utils/githooks/find_base.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
# /*
# * (C) Copyright 2024 Intel Corporation.
# * (C) Copyright 2025 Hewlett Packard Enterprise Development LP
# *
# * SPDX-License-Identifier: BSD-2-Clause-Patent
# */
Expand Down
7 changes: 6 additions & 1 deletion utils/githooks/git-version.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#

VERSION=$(git --version | sed -ne 's/^[^0-9]*\([[0-9\.]*\).*/\1/p')
if [ -z "$VERSION" ]; then
Expand Down
7 changes: 4 additions & 3 deletions utils/githooks/hook_base.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down Expand Up @@ -41,8 +42,8 @@ run-parts() {
# don't run vim .swp files
[ "${i%.sw?}" != "${i}" ] && continue
skip_item=false
for skip in "${skip_list[@]}"; do
if [[ "${i}" =~ ${skip} ]]; then
for skip in "${skip_list[@]:-}"; do
if [[ -n "${skip}" ]] && [[ "${i}" =~ ${skip} ]]; then
skip_item=true
echo "Skipping ${i}"
break
Expand Down
5 changes: 4 additions & 1 deletion utils/githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
set -eu

. utils/githooks/hook_base.sh
3 changes: 2 additions & 1 deletion utils/githooks/pre-commit.d/10-update-copyright.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2022-2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down
3 changes: 2 additions & 1 deletion utils/githooks/pre-commit.d/20-codespell.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down
3 changes: 2 additions & 1 deletion utils/githooks/pre-commit.d/30-Jenkinsfile.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2023-2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down
3 changes: 2 additions & 1 deletion utils/githooks/pre-commit.d/40-yamllint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2022-2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down
3 changes: 2 additions & 1 deletion utils/githooks/pre-commit.d/50-clang-format.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2022-2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down
3 changes: 2 additions & 1 deletion utils/githooks/pre-commit.d/60-gofmt.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2022-2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down
3 changes: 2 additions & 1 deletion utils/githooks/pre-commit.d/70-isort.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2023-2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down
3 changes: 2 additions & 1 deletion utils/githooks/pre-commit.d/71-flake.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2022-2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down
3 changes: 2 additions & 1 deletion utils/githooks/pre-commit.d/72-pylint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2022-2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down
3 changes: 2 additions & 1 deletion utils/githooks/pre-commit.d/73-ftest.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2024 Intel Corporation.
# Copyright 2025 Hewlett Packard Enterprise Development LP
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
Expand Down
5 changes: 4 additions & 1 deletion utils/githooks/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Copyright 2025 Hewlett Packard Enterprise Development LP
#

. utils/githooks/hook_base.sh
16 changes: 11 additions & 5 deletions utils/rpms/packaging/get_release_branch
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#!/bin/bash

#!/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
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
Expand Down

0 comments on commit 17c86a1

Please sign in to comment.