Skip to content

Commit 2cfff15

Browse files
EricWittmannjsenko
authored andcommitted
Created a pre-commit hook for regenerating the operator install.yaml file
1 parent 44edcc5 commit 2cfff15

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.githooks/pre-commit

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Define the directory to monitor
4+
WATCHED_DIR="operator/model/"
5+
6+
# Get the list of changed files in the staging area
7+
CHANGED_FILES=$(git diff --cached --name-only)
8+
9+
# Check if any file in the watched directory has been modified
10+
FILES_TO_CHECK=$(echo "$CHANGED_FILES" | grep "^$WATCHED_DIR")
11+
12+
# If no changes detected in the directory, exit successfully
13+
if [ -z "$FILES_TO_CHECK" ]; then
14+
echo "No changes detected to Operator Model, skipping install.yaml regen."
15+
exit 0
16+
fi
17+
18+
# Run your custom command (e.g., linting, formatting, tests, etc.)
19+
echo "Changes detected to Operator Model. Generating install.yaml file..."
20+
21+
# Update the install.yaml file (regenerate it)
22+
cd operator
23+
make SKIP_TESTS=true build INSTALL_FILE=install/install.yaml dist-install-file > /dev/null 2>&1
24+
25+
# Capture the exit code of the command
26+
EXIT_CODE=$?
27+
28+
# Exit with the appropriate status
29+
if [ $EXIT_CODE -ne 0 ]; then
30+
echo "Failed to regenerate install.yaml file."
31+
exit 1
32+
fi
33+
34+
echo "Successfully generated install.yaml."
35+
git add ./install/install.yaml
36+
exit 0

install-githooks.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
cp .githooks/* .git/hooks/.

0 commit comments

Comments
 (0)