-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathpre-commit-zigflow.sh
More file actions
executable file
·64 lines (53 loc) · 1.67 KB
/
pre-commit-zigflow.sh
File metadata and controls
executable file
·64 lines (53 loc) · 1.67 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
# Copyright 2025 - 2026 Zigflow authors <https://github.com/zigflow/zigflow/graphs/contributors>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -euo pipefail
# pre-commit provides the rev (e.g. v0.8.1)
VERSION="${PRE_COMMIT_REV}"
VERSION="${VERSION#v}" # strip leading v
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
# Match goreleaser name_template
case "$ARCH" in
x86_64) ARCH="x86_64" ;;
amd64) ARCH="x86_64" ;;
arm64|aarch64) ARCH="arm64" ;;
i386|i686) ARCH="i386" ;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
case "$OS" in
linux) OS="linux" ;;
darwin) OS="darwin" ;;
msys*|mingw*|cygwin*)
OS="windows"
;;
*)
echo "Unsupported OS: $OS"
exit 1
;;
esac
CACHE_DIR="${PRE_COMMIT_HOME:-$HOME/.cache/pre-commit}/zigflow"
BIN_NAME="zigflow_${OS}_${ARCH}"
BIN_PATH="${CACHE_DIR}/${BIN_NAME}-${VERSION}"
if [ ! -f "$BIN_PATH" ]; then
mkdir -p "$CACHE_DIR"
URL="https://github.com/zigflow/zigflow/releases/download/v${VERSION}/${BIN_NAME}"
echo "Downloading Zigflow ${VERSION} (${OS}/${ARCH})..."
curl -sSL -o "$BIN_PATH" "$URL"
chmod +x "$BIN_PATH"
fi
exec "$BIN_PATH" graph inject "$@"