Home > database >  Symfony versioning of a site based on GIT version
Symfony versioning of a site based on GIT version

Time:12-17

OK, a question that seems to be harder (for me) then it appears at first. I develop sites with the symphony framework. But some of the sites are put on servers to which I have no direct access. So, in order to keep track if the latest version is put, I have added a value in the HTML header of the login page. Now I always manually update this value (in the TWIG). And now the question I'm struggling with:

Is it possible to "automate" that the latest value of the GIT commit is added automatically (and transparently, so meaning no effort is required)?
I've been thinking of adding a value to the .env file and trying to get this populated with the correct value, but to be honest I'm a bit struggling to see how I can make this work....

If there are other suggestions to keep a decent version tracking which is relatively transparent for the actual users of the site, then that is of course also welcome...

CodePudding user response:

You can think about and select from at least 2 strategies

Clean and smudge filters

In-file replacement, as it (done|expect to be) now

As explained in Keyword Expansion chapter in GitBook

In the .gitattributes file, you can set a filter for particular paths and then set up scripts that will process files just before they’re checked out and just before they’re staged

I.e have some "magic-string" expanding into anything you want to have in WorkTree and collapsed into original form before placing back into repo, thus - don't appear as content-changes in git's history

Also, for anything you want to have, output of git describe (or any other inique-id generator) may be good candidate, you have to have only at least one tag in repo

Export-subst

External file, appearing on git archive operation in an archive-target automagically with any custom content inside. Can be included into any twig-template or page

No script-coding for smudge|clean filters, only file(s) with git log’s formatting and keyword-expansion processing

  • Related