Verbatim:Development/commithooks

From MozillaWiki
Jump to: navigation, search

Verbatim » Development Planning » Commit Hooks

We modified Pootle to support pre/post commit hooks. This lets us do things like run x2y scripts on our .po files so we can actually commit .lang (or whatever) files to SVN but still modify them as .po files in Verbatim.

  • All scripts go in the root of the scriptsdirectory as set in your pootle.prefs
  • Scripts are to be written in python
  • All scripts need to be named with the project shortname. For example, a project with a shortname of "amo" would have a filename of amo.py.

Interface

All scripts should define the following functions, even if they are empty:

  • initialize(projectdir, languagecode)
    • This is passed a project directory and a language code. This is used to prepare a locale for use by verbatim. If any scripts need to run this is where to do it. This is a destructive method (if you have existing data it might be overwritten)
  • precommit(committedfile, author, message)
    • This is called before the file is committed and should do anything to the files before they need to be committed. This function must return a list of the files to be committed.
  • postcommit(committedfile, success)
    • Called after a commit. Success is a boolean.
  • preupdate(updatedfile)
    • This function must return a list of the files to be updated from the repository.
  • postupdate(updatedfile)