new_git_repository shallow_since 字段格式

new_git_repository shallow_since field format

我有一个 new_git_repository 包含:

new_git_repository(
    name = "hyperscan",
    build_file = "//external-deps/hyperscan:BUILD",
    commit = "[COMMIT_HASH]",
    remote = "https://github.com/intel/hyperscan.git",
    shallow_since = "2018-07-09",
)

构建时说:

DEBUG: Rule 'hyperscan' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1531154744 -0400"

根据 thisshallow_since 格式不应该是 YYYY-MM-DD 吗?
接下来,shallow_since = "1531154744 -0400" 是什么意思?!

Bazel 不处理指定为 shallow_since 属性的字符串,而是将其作为 --shallow-since 参数直接传递给 git。可以在Bazel源码中看到here.

您看到的值是 Git 内部日期格式,即 <unix timestamp> <time zone offset>,其中 <unix timestamp> 是自 UNIX 纪元以来的秒数。 <time zone offset> 是与 UTC 的正或负偏移量。例如 CET(比 UTC 早 1 小时)是 +0100.

Hereunix timestamp 与人类可读的 date/time 之间转换的工具。

Bazel 使用 git log --date=raw 获取提交的时间戳,然后与 shallow_since 的值进行字符串比较。在我看来,这是 Bazel 中的一个错误——它应该进行日期比较。

如评论中所述,您可以使用 git log --date=raw 获取所需提交的 commit sha 和时间 (shallow_since)。