1

I have a project on Heroku with a file, say test.csv. I didn't make any change to this .csv file, but to my main.py file. When I do git push heroku master and try to retrieve the modified date of the test.csv via:

time.gmtime(os.path.getmtime('test.csv'))

I get the date/time of the push to heroku instead of the actual last modified date/time. I also have this project in GitHub, and the modified date/time is correct in on the website.

Wondering why it does this, and if there's any way I could get the actual last modified date of a file in Heroku.


Edit: From talking to @VonC, it appears that what I need is to get the date that the file was last committed, not modified, as the modified date will get changed every time a commit happens. Will try that.

Art
  • 453
  • 4
  • 12

1 Answers1

0

I mentioned before that Git does not record timestamp.
What you would get locally is the timestamp of the last clone or checkout.

Check with git show if the last commit (pushed to heroku) did include test.csv.
Even if you did not modify it directly, a setting like git config core.autocrlf might have changed it automatically.

In python:

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Sorry I'm not very familiar with `git`. Tried doing `git show heroku master` but that doesn't work. How do I do that? What got me curious is that the repo in GitHub and in Heroku should be very similar, but the one in GitHub got the correct date. – Art Sep 17 '19 at 04:50
  • @Art Again, the date seen locally is the one of the last clone/checkout, not the one of the remote repository. And assuming the last commit is the one pushed to heroku, a simply git show (no argument) would be enough. – VonC Sep 17 '19 at 04:52
  • Checked... `test.csv` doesn't appear on `git show`. – Art Sep 17 '19 at 04:54
  • @Art Then as mentioned at the beginning of the answer, the timestamp seen if the one of the last local clone/checkout, since Git itself does not record timestamps. – VonC Sep 17 '19 at 04:55
  • So you're saying that GitHub's ability to show last modified date for each file is GitHub's own feature? – Art Sep 17 '19 at 05:25
  • @Art on GitHub, you see the timestamp of the last commit, not the last modification. A file can have been modified 3 days ago, but committed 3 seconds ago: the latter time will be seen on GitHub. See https://stackoverflow.com/a/50195616/6309. – VonC Sep 17 '19 at 06:01
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/199553/discussion-between-art-and-vonc). – Art Sep 17 '19 at 06:17