ackama / rails-template

Application template for Rails 7 projects; preloaded with best practices for TDD, security, deployment, and developer productivity.
Other
294 stars 15 forks source link

fix: return `nil` if revision time ends up being zero #506

Closed G-Rath closed 10 months ago

G-Rath commented 10 months ago

String#to_i works by returning all the digits in a string up to the first non-digit that isn't _ (they're treated as separators) or the end of the string - if no digits are found then zero is returned.

One of the feedback items on #461 was that when we can't determine the revision time we should explicitly return nil instead of a Time; but the above logic of String#to_i means we can end up returning the start of the epoch which goes against that.

This changes our logic so that we explicitly return nil if we end up getting a zero, ensuring our "Unknown time" logic will be triggered.