Something went wrong. Try again.
Web frontend and supporting services for lance.blue
Something went wrong. Try again.
688 B · 18 lines
Shell
12345678910111213141516171819#!/usr/bin/env bash# Print the ref a build is named after: <branch>-<sha12>, plus -dirty when# the tree has uncommitted changes. Slashes and anything else awkward in a# docker tag or S3 prefix become dashes; a detached HEAD contributes no# branch. Callers may set BUILD_REF instead, so a push computes the ref once# and hands it to the build it runs.set -euo pipefail
ref=$(git rev-parse --short=12 HEAD)branch=$(git rev-parse --abbrev-ref HEAD)if [ "$branch" != HEAD ]; then ref="$(printf '%s' "$branch" | tr -c 'A-Za-z0-9_.-' '-')-$ref"fiif [ -n "$(git status --porcelain)" ]; then ref="$ref-dirty" echo "working tree is dirty; ref is $ref" >&2fiprintf '%s\n' "$ref"