Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use /bin/sh for pre-commit script for portability #2346

Merged
merged 1 commit into from
Jun 7, 2024
Merged
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
23 changes: 10 additions & 13 deletions tools/pre-commit-tfdoc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh

# Copyright 2024 Google LLC
#
Expand All @@ -16,19 +16,16 @@

set -e

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$0")")

files=("$@")
declare -A directories

for file in "${files[@]}"; do
dir=$(dirname "${file}")
for file in "$@"; do
if [ -d "${file}" ]; then
dir="${file}"
else
dir=$(dirname "${file}")
fi
if [ -f "${dir}/README.md" ] && [ -f "${dir}/main.tf" ]; then
directories["${dir}"]=1
echo "${dir}"
fi
done

for dir in "${!directories[@]}"; do # iterate over keys in directories
echo python "${SCRIPT_DIR}/tfdoc.py" "${dir}"
python "${SCRIPT_DIR}/tfdoc.py" "${dir}"
done
done | sort | uniq | xargs -I {} /bin/sh -c "echo python \"${SCRIPT_DIR}/tfdoc.py\" {} ; python \"${SCRIPT_DIR}/tfdoc.py\" {}"
Loading