Skip to content

Commit 0639eaa

Browse files
authored
in lint, fix timestamp comparison when timezone does not match (#5688)
Git by defaults returns commit timestamp according to the committer's time zone instead of the local one, breaking the simple alphanumeric comparison for timestamps that we use in lint. Force the timezone to UTC so that comparison is correct regardless of committer timezone.
1 parent 571193d commit 0639eaa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# beacon_chain
2-
# Copyright (c) 2020-2023 Status Research & Development GmbH
2+
# Copyright (c) 2020-2024 Status Research & Development GmbH
33
# Licensed and distributed under either of
44
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
55
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -238,7 +238,7 @@ jobs:
238238
run: |
239239
while read -r file; do
240240
commit="$(git -C "$file" rev-parse HEAD)"
241-
commit_date=$(git -C "$file" show -s --format='%ci' HEAD)
241+
commit_date=$(TZ=UTC0 git -C "$file" show -s --format='%cd' --date=iso-local HEAD)
242242
if ! branch="$(git config -f .gitmodules --get "submodule.$file.branch")"; then
243243
echo "Submodule '$file': '.gitmodules' lacks 'branch' entry"
244244
exit 2
@@ -248,7 +248,7 @@ jobs:
248248
echo "Submodule '$file': Failed to fetch '$branch': $error (1)"
249249
exit 2
250250
fi
251-
branch_commit_date=$(git -C "$file" show -s --format='%ci' "refs/remotes/origin/${branch}")
251+
branch_commit_date=$(TZ=UTC0 git -C "$file" show -s --format='%cd' --date=iso-local "refs/remotes/origin/${branch}")
252252
if [[ "${commit_date}" > "${branch_commit_date}" ]]; then
253253
echo "Submodule '$file': '$commit' ($commit_date) is more recent than latest '$branch' ($branch_commit_date) (branch config: '.gitmodules')"
254254
exit 2

0 commit comments

Comments
 (0)