Nightfirecat / RealmEye-API

An easy way to access your character data via RealmEye.
MIT License
13 stars 7 forks source link

Add git commit hash field? #24

Closed Nightfirecat closed 8 years ago

Nightfirecat commented 8 years ago

For testing/bug reporting, it may be helpful to include the git hash in the JSON response or as an HTTP header. https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Keyword-Expansion http://stackoverflow.com/questions/16524225/how-can-i-populate-the-git-commit-id-into-a-file-when-i-commit

Keeping this in mind, it's possible some part of the code involved may go missing, so the injection should be dependent on the variable being initialized and set. Something like:

if (isset($commit)) {
    $json["commit"] = $commit;
}

Furthermore, this may cause problems if maintaining a deployment workflow that boils down to running Git on the server and executing git pull to keep the code up-to-date. I need to do more reading on this to make sure I can execute this correctly.

Nightfirecat commented 8 years ago

Turns out this was much simpler than implementing a full smudge-clean filter (a bit overkill for this situation). Instead, I can utilize the ident function of .gitattributes to handle this, with some string formatting to get just the right stuff. (can be seen in the version-header branch)

I'm going to hold off merging it until tomorrow since I want to simplify the string processing (using str_replace once or twice rather than regex) and squash the commits.

Nightfirecat commented 8 years ago

Note, I should probably update the README to include a note that bugs should typically be submitted with the commit hash of the offending version. This also may be a notable enough feature to bump the minor version to 3.1?