Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .claude/skills/build-lookup/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Run the helper script:
bash .claude/skills/build-lookup/scripts/build-lookup.sh <versionCode>
```

The script fetches and counts from `origin/code/cash`, the branch builds are cut
from, so a stale or detached local checkout does not matter. Pass `--ref <ref>`
to count from another ref.

The script emits JSON:

```json
Expand Down
37 changes: 30 additions & 7 deletions .claude/skills/build-lookup/scripts/build-lookup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,49 @@
# apps/flipcash/app/build.gradle.kts:20-25). versionCode N = the Nth commit
# from the root of the repo.
#
# Builds are cut from code/cash, so commits are counted from origin/code/cash
# (fetched first), not from the local HEAD, which may be behind or on another
# branch.
#
# Usage:
# ./build-lookup.sh <versionCode>
# ./build-lookup.sh 3797
# ./build-lookup.sh 3797 --ref <ref> # count from another ref
#
# Output: JSON with commit_sha, commit_short, commit_message, and (if found)
# the GitHub Actions run ID and URL for the Flipcash2 workflow.

set -euo pipefail

if [[ $# -lt 1 ]]; then
echo "Usage: build-lookup.sh <versionCode>" >&2
echo "Usage: build-lookup.sh <versionCode> [--ref <ref>]" >&2
exit 1
fi

VERSION_CODE="$1"
VERSION_CODE="$1"; shift
REF="origin/code/cash"
while [[ $# -gt 0 ]]; do
case "$1" in
--ref) REF="$2"; shift 2 ;;
*) echo "Unknown argument: $1" >&2; exit 1 ;;
esac
done

if [[ "$REF" == "origin/code/cash" ]]; then
git fetch --quiet origin code/cash 2>/dev/null \
|| echo "WARN: could not fetch origin/code/cash; using the local copy" >&2
fi
WORKFLOW_ID="229420296" # "Flipcash2 Build and Deploy"

# ── Resolve versionCode to commit ───────────────────────────────────
# versionCode = git rev-list --count HEAD at the time of build.
# The Nth commit (1-indexed from root) is at position N in `git rev-list --reverse HEAD`.
# Equivalently: git rev-list HEAD | sed -n '<offset>p' where offset = total - N + 1.
# The Nth commit (1-indexed from root) is at position N in `git rev-list --reverse $REF`.
# Equivalently: git rev-list $REF | sed -n '<offset>p' where offset = total - N + 1.

TOTAL=$(git rev-list --count HEAD)
TOTAL=$(git rev-list --count "$REF")

if (( VERSION_CODE > TOTAL )); then
echo "ERROR: versionCode $VERSION_CODE exceeds current commit count ($TOTAL)" >&2
echo "ERROR: versionCode $VERSION_CODE exceeds the commit count of $REF ($TOTAL)" >&2
exit 1
fi

Expand All @@ -40,7 +57,13 @@ if (( VERSION_CODE < 1 )); then
fi

OFFSET=$(( TOTAL - VERSION_CODE + 1 ))
COMMIT_SHA=$(git rev-list HEAD | sed -n "${OFFSET}p")
COMMIT_SHA=$(git rev-list "$REF" | sed -n "${OFFSET}p")

# The offset assumes linear history. Confirm the commit really is the Nth.
if [[ "$(git rev-list --count "$COMMIT_SHA")" != "$VERSION_CODE" ]]; then
echo "ERROR: commit ${COMMIT_SHA:0:9} on $REF has $(git rev-list --count "$COMMIT_SHA") ancestors, not $VERSION_CODE (non-linear history?)" >&2
exit 1
fi
COMMIT_SHORT="${COMMIT_SHA:0:9}"
COMMIT_MESSAGE=$(git log -1 --format='%s' "$COMMIT_SHA")
COMMIT_DATE=$(git log -1 --format='%aI' "$COMMIT_SHA")
Expand Down
8 changes: 7 additions & 1 deletion .claude/skills/triage/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ If the script exits non-zero, stop and report the error to the user.
## Step 2 — Pull event detail

Fetch `event_url` (include header `Authorization: token $BUGSNAG_TOKEN`).
Source `.env` from the repo root if the variable is not already set.
The token lives in `.env` or `.env.local` at the repo root, as the script reads
it; load both in the same shell as the request:

```bash
set -a; [ -f .env ] && . ./.env; [ -f .env.local ] && . ./.env.local; set +a
curl -s -H "Authorization: token $BUGSNAG_TOKEN" "<event_url>"
```

Parse the response using the event shape documented in
`.claude/skills/triage/references/event-shape.md`.
Expand Down
Loading