#!/usr/bin/env bash set -euo pipefail ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd) mapfile -d '' -t candidate_files < <( git -C "$ROOT" ls-files \ --cached \ --others \ --exclude-standard \ -z \ -- android | LC_ALL=C sort -z ) source_files=() for relative_path in "${candidate_files[@]}"; do absolute_path="$ROOT/$relative_path" # `git ls-files --cached` also reports tracked paths deleted in the working # tree. They are not inputs to the artifact being built, so exclude them # from the working-tree fingerprint instead of treating a valid deletion as # a broken source tree. if [[ ! -e "$absolute_path" && ! -L "$absolute_path" ]]; then continue fi source_files+=("$relative_path") done if [[ "${#source_files[@]}" -eq 0 ]]; then echo "No Android source files were found." >&2 exit 1 fi { for relative_path in "${source_files[@]}"; do absolute_path="$ROOT/$relative_path" if [[ ! -f "$absolute_path" ]]; then echo "Android source input is not a regular file: $relative_path" >&2 exit 1 fi printf '%s\0' "$relative_path" sha256sum "$absolute_path" | awk '{print $1}' done } | sha256sum | awk '{print $1}'