'new_git_repository shallow_since field format

I've a new_git_repository containing:

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",
)

When building it says:

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

According to this, shouldn't the shallow_since format be of YYYY-MM-DD?
And next, what does shallow_since = "1531154744 -0400" mean?!



Solution 1:[1]

Bazel does not process the string specified as shallow_since attribute and passes it directly to git as --shallow-since parameter. It can be seen in Bazel source code here.

The value you see is Git internal date format which is <unix timestamp> <time zone offset>, where <unix timestamp> is the number of seconds since the UNIX epoch. <time zone offset> is a positive or negative offset from UTC. For example CET (which is 1 hour ahead of UTC) is +0100.

Here is the tool for unix timestamp conversion to the human-readable date/time and back.

Bazel uses git log --date=raw to get the timestamp of the commit, and then does a string comparison with the value of shallow_since. In my opinion, it is a bug in Bazel - it should do a date comparison instead.

Solution 2:[2]

As specified in the comments, you can use git log --date=raw to get the commit sha and the time (shallow_since) of the desired commit.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Amin