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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
馃悰 make getVersion() show the commit date, not checkout date #2443
Conversation
Currently, getVersion() shows the date when the HEAD of the local git repository was last changed, not the date of the current commit. This commit fixes that behavior.
This requires to have git installed and executable by the webserver user which may not always be the case. I wonder how often it happens that someone is running a commit that's not the head. |
No, this is not how it works. If I make a I will look into making it work without access to the shell. |
Under some circumstances, there may be no git or no shell access available. This gets the commit date manually.
$date = date('Y-m-d',array_pop($chunk)); | ||
if($date) $version['date'] = $date; | ||
if ($date = shell_exec("git log -1 --pretty=format:'%cd' --date=short")) { | ||
$version['date'] = hsc($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.
can we skip the shell access completely and always do it manually?
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.
No, because manual may not reliably work either. Git tends to pack objects to save space locally and I'm not sure how to get that specific commit out of such a pack without git itself.
This protects against the current commit being packed and not available as an object and against zlib not being available. More information about commits being packed and thus not available can be found here: https://git-scm.com/book/en/v2/Git-Internals-Packfiles
Is this PR now fine? |
Currently, getVersion() shows the date when the HEAD of the local git repository was last changed, not the date of the current commit. This pull request fixes that behavior.
Steps to reproduce: