-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-commit.sh
More file actions
executable file
·31 lines (26 loc) · 886 Bytes
/
Copy pathrun-commit.sh
File metadata and controls
executable file
·31 lines (26 loc) · 886 Bytes
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
#!/bin/sh
# POSIX counterpart of run-commit.cmd: check the API key, stage everything,
# then hand every argument through to the commitclerk package.
set -eu
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
if [ -z "${OPENAI_API_KEY:-}" ]; then
echo "Error: OPENAI_API_KEY is not set." >&2
exit 2
fi
if command -v python3 >/dev/null 2>&1; then
PYTHON=python3
elif command -v python >/dev/null 2>&1; then
PYTHON=python
else
echo "Error: no python3 or python on PATH." >&2
exit 2
fi
# -A, not a glob: a glob skips dotfiles and never records deletions.
if ! git add -A; then
echo "git add failed." >&2
exit 1
fi
# Works whether this wrapper sits next to the package (a repo checkout) or next to
# a downloaded single-file commitclerk.py: -m finds either on the path.
export PYTHONPATH="$SCRIPT_DIR:$PYTHONPATH"
exec "$PYTHON" -m commitclerk "$@"