setup-hooks/set-source-date-epoch-to-latest.sh: handle $path that starts with dash

Without the change `updateSourceDateEpoch` fails on tarballs like
`diffoscope-269` that contain single top-level `-269` root as:

    diffoscope> source root is -269
    diffoscope> find: unknown predicate `-269'
    diffoscope> chmod: invalid mode: ‘-269’
    diffoscope> Try 'chmod --help' for more information.

Currently `diffoscope-269` has a `sourceRoot = "./-269";` workaround to
bypass the failure.

Co-authored-by: Philip Taron <philip.taron@gmail.com>
This commit is contained in:
Sergei Trofimovich 2024-06-03 07:28:26 +01:00
parent 192b17b569
commit a3f1b476c7

View File

@ -1,5 +1,8 @@
updateSourceDateEpoch() {
local path="$1"
# Avoid passing option-looking directory to find. The example is diffoscope-269:
# https://salsa.debian.org/reproducible-builds/diffoscope/-/issues/378
[[ $path == -* ]] && path="./$path"
# Get the last modification time of all regular files, sort them,
# and get the most recent. Maybe we should use