-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
42 lines (32 loc) · 1.19 KB
/
entrypoint.sh
File metadata and controls
42 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
set -e
SW_REPO_DIR="/src"
ACTION_REPO_DIR="/action"
export XDG_CACHE_HOME="/tmp/.pre-commit-cache"
cd "$SW_REPO_DIR" || exit 1
git config --global --add safe.directory "$SW_REPO_DIR"
echo "=== Configuration Status ==="
echo "EXCLUDE_REGEX: ${EXCLUDE_REGEX:-<not set>}"
echo "CODESPELL_IGNORE_WORDS: ${CODESPELL_IGNORE_WORDS:-<not set>}"
echo "CODESPELL_SKIP_PATHS: ${CODESPELL_SKIP_PATHS:-<not set>}"
echo "==========================="
if [ -n "$EXCLUDE_REGEX" ] || [ -n "$CODESPELL_IGNORE_WORDS" ] || [ -n "$CODESPELL_SKIP_PATHS" ]; then
SCRIPT_PATH="$ACTION_REPO_DIR/handle_custom_inputs.py"
if [ ! -s "$SCRIPT_PATH" ]; then
echo "ERROR: missing or empty handler script: $SCRIPT_PATH" >&2
exit 1
fi
python3 "$SCRIPT_PATH"
fi
echo "Installing pre-commit hooks..."
pre-commit install-hooks --config /action/.pre-commit-config.yaml
echo "Running pre-commit..."
set +e
pre-commit run --config /action/.pre-commit-config.yaml --all-files 2>&1 | tee CodingConventionTool.txt
PC_EXIT=${PIPESTATUS[0]}
set -e
git diff > code-fix.patch || echo "No changes to patch."
if [ "$PC_EXIT" -ne 0 ]; then
echo "Pre-commit failed with exit code $PC_EXIT"
exit "$PC_EXIT"
fi