Agent shells often miss the brew shellenv (clide FR-1), so bare 'tea' 127s. The wrapper now falls back to /home/linuxbrew/.linuxbrew/bin/tea. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
42 lines
1.1 KiB
Bash
Executable File
42 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Post a comment to a Gitea PR or issue.
|
|
# Usage: tea-comment <number> "comment body"
|
|
# tea-comment <number> @/path/to/file.md
|
|
set -euo pipefail
|
|
|
|
if [[ $# -lt 2 ]]; then
|
|
echo "Usage: tea-comment <number> <comment|@filepath>" >&2
|
|
exit 1
|
|
fi
|
|
|
|
NUMBER="$1"
|
|
INPUT="$2"
|
|
|
|
# Resolve tea: PATH first, then the known linuxbrew keg (agent shells often
|
|
# miss the brew shellenv — clide FR-1).
|
|
TEA="$(command -v tea || true)"
|
|
[[ -n "$TEA" ]] || TEA="/home/linuxbrew/.linuxbrew/bin/tea"
|
|
if [[ ! -x "$TEA" ]]; then
|
|
echo "Error: tea CLI not found (PATH or /home/linuxbrew/.linuxbrew/bin)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# If the body starts with @, read from file
|
|
if [[ "$INPUT" == @* ]]; then
|
|
FILEPATH="${INPUT#@}"
|
|
if [[ ! -f "$FILEPATH" ]]; then
|
|
echo "Error: file not found: $FILEPATH" >&2
|
|
exit 1
|
|
fi
|
|
BODY=$(cat "$FILEPATH")
|
|
else
|
|
BODY="$INPUT"
|
|
fi
|
|
|
|
HASH=$(echo -n "$BODY" | md5sum | cut -c1-8)
|
|
TMPFILE="/tmp/tea-comment-${NUMBER}-${HASH}.md"
|
|
trap 'rm -f "$TMPFILE"' EXIT
|
|
|
|
printf '%s' "$BODY" > "$TMPFILE"
|
|
"$TEA" comment --login schweitz --repo jpmschweitzer/settled-reach "$NUMBER" "$(cat "$TMPFILE")"
|