2

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?!

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Emran
  • 544
  • 7
  • 26

2 Answers2

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.

Konstantin Erman
  • 551
  • 6
  • 14
  • OK. But, git clone accepts both formats (`unix timestamp` and `YYYY-MM-DD`) as a `shallow_since` argument. The problem is: when I set a shallow_since in the format of `YYYY-MM-DD` bazel warns me to set the shallow_since! (Seems it discards the date or something similar) – Emran Mar 24 '20 at 08:39
  • 2
    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. – Konstantin Erman Mar 24 '20 at 13:04
  • I'll appreciate if you add this important point to the answer so I can accept it as a correct. – Emran Mar 26 '20 at 12:23
0

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.

Amin Ya
  • 1,515
  • 1
  • 19
  • 30