GitHash 1.5.0 released, this release adds support for PHP 8.5.

The package is to get the current git hash (short or long) in your application.

https://packagist.org/packages/tjvb/githash

#PHP #Git #PHP85 #package #oss #release

tjvb/githash - Packagist.org

Get the current git hash from your project.

And I released Laravel GitHash 1.9.0

The package is to get the current git hash (short or long) in your Laravel application.

https://packagist.org/packages/tjvb/laravel-githash

#PHP #PHP85 #Laravel #release #oss

tjvb/laravel-githash - Packagist.org

Get the current git hash from your project, show it in your blade or add it to your logs.

@tvbeek I’m curious if this works for projects packaged with `git archive`.

@ramsey Interesting question, I personal never have used a git archive.

If I read it correctly it creates an archive from your repository, but maybe I'm wrong.

The current finders doesn't work with an archive ( see: https://gitlab.com/tjvb/githash#different-hashfinders )

And I'm thinking, how do you run a project that is inside an archive 🤔 but if possible it can be interesting to add support for it.

tjvb / GitHash · GitLab

Find the hash of the current commit from a git repository.

GitLab
@tvbeek When you download zip files from GitHub (which is what Composer defaults to unless using --prefer-source), those zip files are created using `git archive`. That command is what uses the `.gitattributes` file to ignore files from the distribution.

@ramsey I did a fast check and in the zip file I didn't see any reference about a version.

Maybe I need to document in a clear way that the package target is to get the version from the project/application and not from a dependency.

@tvbeek No worries. I think it’s clear that this isn’t intended for use with dependencies. I was mainly curious for those who distribute full applications via archives—I guess they should have some kind of build step that sets the version before bundling it; I’ve been looking for a way to do this without that build step.

@ramsey The Laravel wrapper for the package has the support for a cache file.

That is something that can be used in a build step.

There is an example in the readme about the usage with envoyer: https://gitlab.com/tjvb/laravel-githash#envoyer-example

The base package doesn't have any cache file support build in. Currently I think it is good to let the application handle it to keep the package small.

Thanks for the messages, it is good and nice to think about it again 😃👍

tjvb / Laravel GitHash · GitLab

GitLab.com

GitLab