3

Our project uses gettext to allow for multiple languages. Further, there is a *.bat and *.sh file, which generates the current POT file both from the PHP files and Smarty templates.

Is there a way to configure PHPStorm to execute an external tool (for example the bat file), before doing a GIT commit? In the commit window, there is only the possibility to execute a tool after commit. However, after doing changes in the code, I would like to update the POT first, then commit the code.

Daniel
  • 1,398
  • 4
  • 20
  • 47

1 Answers1

1

That looks like the clean step of a content filter driver:

clean

(image shown in "Customizing Git - Git Attributes", from "Pro Git book")

The commit would trigger the clean script in order to modify the files, before the commit.

The clean script is:

  • declared with git config filter.<filtername>.clean ./<filterscript>
  • used in a .gitattributes file.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you very much for your answer, this indeed looks very promising. One question, though: We have developers working under UNIX and Windows, hence there is a *.bat file and an *.sh file. Both essentially do the same job. Is there a way in the `.gitattributes` file to execute the batch file when in Windows environment and the shell script when in UNIX? – Daniel Feb 23 '15 at 09:51
  • @waza-ari no, the clean script should be a bash one, not a `.bat`. Even on Windows. – VonC Feb 23 '15 at 09:52
  • Okay, thank you very much @VonC. It works now, I will accept the answer. Just have a little problem with line endings remaining, but I will look for other answers or post a new question. – Daniel Feb 23 '15 at 10:16
  • one more question please: is it possible to declare the filter "automatically" using a file from repository? Now, the .gitattributes file, which uses the filter is checked in the repository, as well as the bash script. I would like to "automate" the filter setup for new developers, such that after checkout the filter is both declared and used. – Daniel Feb 23 '15 at 13:12
  • @waza-ari you cannot "automate" the config which is; by definition, local. You only can put in a README that the user should add an include directive (which can point to a versionned config file: http://stackoverflow.com/a/9733277/6309) – VonC Feb 23 '15 at 13:28