I want to modify some configuration strings in a git version controlled php script, according to the environment I am using the code in the repository.
I want to set up a smudge/clean filter to modify the configuration string in the code according to the platform, I am checking out (dev/testing). My scripts are in ~/scripts and I want to add a config file ~/scripts/config to set values used by the script
I have different projects (in different repos) with the same files in it but they should be modified differently, so the script needs to know from which repository it was invoked.
Is there a way to set a project ID maybe in the .gitattributes file which is passed as an environment variable to the filter script?
EXAMPLE:
content of .gitattributes:
PROJECT_ID = "ProjectX"
content of smudge script (pseudo code):
host = getConfigValueFromFile(projectXhost)
if $PROJECT_ID == "ProjectX" then
print 'host=$host'
I have found an answer by myself:
The clean/smudge script is executed with the (new) repos directory as the working directory. So it is possible to put a file e.g.
.projectIDin your repository and read its content in the smudge script.