3.11. External Commit Hooks

Elego ComPact can be instructed to interact with any problem report or request tracking system by the definition of external commands that are hooked into several important actions and procedures the Elego ComPact package and project management tools perform.

The available hooks are

external-package-commit-hook
external-package-release-hook
external-project-snapshot-hook
external-project-release-hook
external-change-set-hook
external-commit-hook
These hooks are defined in one of the compactrc resources read at startup. The last hook is used as default if any of the more specific hook commands is not defined.

The hook program may be used to simply check the syntax or layout of the log or commit message, to check for the existence of a problem report or change request to which the log message refers, or even to trigger some actions in the problem management or request tracking system. A common action would be to test if the request id mentioned in the log message does indeed exist and is in an open state. More advanced check programs could also extract the indended state change action (for example open --> processed) and try to execute the appropriate database transaction.

The command specified should start with an exclamation mark in order to prevent premature variable substitution right after parsing of the compactrc resource. In the command the following variables may be used:

  {!msg}       -- the complete log message
  {!msgfn}     -- the name of a (temporary) file containing the log message
  {!pkgname}   -- the name of the package or project
  {!pkgroot}   -- absolute local pathname of package or project
  {!user}      -- the current user name
  {!action}    -- one of package-commit, package-release,
                  project-snapshot, project-release, project-change-set
  {!name}      -- the name of the new revision, snapshot, release, or
                  change set
  {!id}        -- request-id extracted from the log message, if present


In Elego ComPact's project management, external check commands may be invoked for the creation of snapshots, releases, and change sets. (More important are probably the commit hooks for the package revisions themselves.) The hook command is invoked before the actual commit or create action is executed. All variables in the command line are substituted prior to the execution (the values of all environment variables from compactrc may be used as well). If the hook command exits with 0, the action is accepted, otherwise it is rejected and the action is abandoned.