-
Notifications
You must be signed in to change notification settings - Fork 16
OTWO-2996 Default to EPOCH time when the git parser don't find a date #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Currently, it defaults to Time.now.utc which is not reasonably fair. Also git commands like git log/show defaults to epoch time.
lib/scm/parsers/git_styled_parser.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. BTW, can we refactor this ? the whole scheme of nested conditional looks ugly to me ... possibly we could use a combination of guard clause and switch/case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the gain, if we do rewrite this code using case..when ? I don't think we can do it in a fewer lines of code, than the nested if.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can write it same number of lines with better readability.
I think i will refactor this code and send you a pull eventually i have a feeling this could be really improved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about trying Time.rfc2822(date). It throws ArgumentError when date is not formatted per RFC2822; we'd catch this exception and return Time.at(0).utc in such cases.
|
Besides the above comments overall it looks good to me. |
|
I've updated the code to address the PR comments. Thanks @amujumdar and @pankajdoharey |
lib/scm/parsers/git_styled_parser.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just call it parse_date. It can be used to parse author or committer date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure Abhay. Updated it.
… parse author/committer date
OTWO-2996 Default to EPOCH time when the git parser don't find a date
Currently, it defaults to Time.now.utc which is not reasonably fair.
Also git commands like git log/show defaults to epoch time.