diff --git a/scripts/artifacts.sh b/scripts/artifacts.sh index f509cd7..9c49037 100755 --- a/scripts/artifacts.sh +++ b/scripts/artifacts.sh @@ -136,9 +136,14 @@ newest() { # Unquoted on purpose: the pathspec must word-split into separate args. # Globbing is off script-wide (`set -f`). + # + # Newest committer time wins. Two commits pushed together can share a + # second, and then the one git log lists first (the descendant, which holds + # both changes) wins: a stable sort on the timestamp alone keeps git's order + # among equals. Sorting on the whole line would break the tie by hash. # shellcheck disable=SC2086 set -- "$(cd "$ROOT" && git log --format='%ct %H' HEAD -- $paths \ - | sort -n | tail -1)" + | sort -s -k1,1nr | head -1)" if [ -z "$1" ]; then echo "artifacts.sh: no commit touches this artifact's shipped files" >&2 exit 1