[Git][reproducible-builds/diffoscope][master] comparators/directory.py: ignore st_size for directories
Chris Lamb (@lamby)
gitlab at salsa.debian.org
Sat Mar 29 17:16:10 UTC 2025
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
6a848187 by Ivan Trubach at 2025-03-27T00:18:45+03:00
comparators/directory.py: ignore st_size for directories
- - - - -
1 changed file:
- diffoscope/comparators/directory.py
Changes:
=====================================
diffoscope/comparators/directory.py
=====================================
@@ -21,6 +21,7 @@ import os
import re
import logging
import subprocess
+from stat import S_ISDIR
from diffoscope.exc import RequiredToolNotFound
from diffoscope.tools import python_module_missing, tool_required
@@ -76,15 +77,19 @@ else:
# compare only what matters
def stat_results_same(stat1, stat2):
- return all(
- getattr(stat1, i) == getattr(stat2, i)
- for i in [
- "st_mode",
- "st_uid",
- "st_gid",
- "st_size",
- "st_mtime",
- ]
+ return stat_result_to_tuple(stat1) == stat_result_to_tuple(stat2)
+
+
+def stat_result_to_tuple(stat):
+ return (
+ stat.st_mode,
+ stat.st_uid,
+ stat.st_gid,
+ # Directory sizes are arbitrary, file system dependent, and may differ,
+ # depending on the history of the directory.
+ # E.g. see https://github.com/NixOS/nixpkgs/issues/393375
+ stat.st_size if not S_ISDIR(stat.st_mode) else None,
+ stat.st_mtime,
)
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/6a848187fc189c567ade287ac242ae459e9130bf
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/6a848187fc189c567ade287ac242ae459e9130bf
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20250329/8c45d4cc/attachment.htm>
More information about the rb-commits
mailing list