···11#!/bin/bash
22-# build-name.sh — Generate a unique build name from git commit hash.
33-# Deterministic: same commit always produces the same name.
44-# Globally unique: different commits produce different names (73,000 combos).
55-# Usage: ./build-name.sh → prints name (e.g., "swift-otter")
66-# ./build-name.sh --bump → (legacy compat, ignored — names come from git hash now)
22+# build-name.sh — Generate a unique build name for each build.
33+# Uses git hash for adj+animal, plus epoch seconds for uniqueness.
44+# Every invocation produces a different name, even for the same commit.
55+# Usage: ./build-name.sh → prints name (e.g., "swift-otter-7a3")
76set -e
8798# 365 animals
···8382NUM_ANIMALS=${#ANIMALS[@]}
8483NUM_ADJ=${#ADJECTIVES[@]}
85848686-# Derive name from git commit hash — deterministic and globally unique
8585+# Mix git hash + epoch for a unique name every build
8786GIT_HASH=$(git rev-parse HEAD 2>/dev/null || echo "0000000000000000000000000000000000000000")
8787+EPOCH=$(date +%s)
88888989-# Use first 8 hex chars for adjective index, next 8 for animal index
9090-# This gives uniform distribution across both arrays
8989+# Adjective from git hash, animal from epoch (so same commit gets different animals)
9190HEX_ADJ="${GIT_HASH:0:8}"
9292-HEX_ANIMAL="${GIT_HASH:8:8}"
9393-9494-# Convert hex to decimal (portable: printf handles this)
9591DEC_ADJ=$(printf '%d' "0x${HEX_ADJ}" 2>/dev/null || echo 0)
9696-DEC_ANIMAL=$(printf '%d' "0x${HEX_ANIMAL}" 2>/dev/null || echo 0)
9797-9892ADJ_IDX=$(( DEC_ADJ % NUM_ADJ ))
9999-ANIMAL_IDX=$(( DEC_ANIMAL % NUM_ANIMALS ))
9393+ANIMAL_IDX=$(( EPOCH % NUM_ANIMALS ))
1009410195echo "${ADJECTIVES[$ADJ_IDX]}-${ANIMALS[$ANIMAL_IDX]}"