YouTube-operational-API
YouTube-operational-API copied to clipboard
Add a retrievable instance version
Related to these StackOverflow questions:
https://stackoverflow.com/q/3442874 https://stackoverflow.com/q/949314
As there doesn't seem to be perfect solution (for people downloading the source code as .zip directly for instance), I added to the end of index.php a mechanism such that git-powered instances will display their commit hashes.
Instead of the file_get_contents can use exec('git rev-parse HEAD'), as it works even if may produce errors on the backend (a cleaner way would be not to display the paratext uses version: ), cf below.
Note that git rev-parse HEAD returns on stderr but nothing on stdout:
fatal: not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
In addition to what is currently done for git-powered instances, ideally for people just downloading .zip, displaying the commit hash would be nice (can only display the previous one) and for people downloading a release having the clean release name would be nice (if there is any release cf #67).
Note that as far as I know just modifying locally a file of the git without committing won't change the version displayed.
What if is on another branch? Modifying locally, doing git reset etc?
Note that current file read .git/refs/heads/main is focused on main branch.
A way could consists in making the PHP code itself compute a/the fingerprint and then store and use it, but it's a bit too complicated for this purpose.