#!/bin/bash
set -euo pipefail

if [[ -z ${GIT_COMMIT-} ]]; then
  GIT_COMMIT=$(git rev-list HEAD --max-count=1)

  status=$(git status --porcelain)
  if [[ ! -z $status ]]; then
    GIT_COMMIT=${GIT_COMMIT}-dirty
  fi
fi

echo ${GIT_COMMIT}