Post-Commit Scripts

Post-commit scripts are run after the items selected in the commit view have been successfully committed to the repository (see the commit process for more information).

A post-commit script can be run in one of two ways:

  1. Once for the entire working copy

    The script is run once. The POSIX path of the working copy’s top folder is passed to the script as its only parameter.

  2. Once for each checked item in the commit view’s Changes list

    The script is run multiple times, once for each checked item in the commit view’s Changes list. The POSIX path of the changed item is passed to the script as its only parameter.

    Cornerstone will abort script execution as soon as the first error is encountered.

Post-commit scripts are only run when the commit operation results in a new revision in the repository, i.e. scripts are not run when Commit Changes is pressed with no items selected in the Changes list.

Selecting a Script for Execution

Post-commit scripts are defined for each working copy:

  1. Start a commit operation by selecting one or more changed items and choosing the Commit command from the Working Copy menu (key equivalent ⌘T).

  2. Expand the Options section at the bottom of the commit view.

  3. Locate the After committing options in the Actions section.

  4. Check the Run script button.

  5. Use the pop-up to choose the script to run.

  6. Specify whether the script should be run once for the entire working copy or once for each item.

Possible Uses for Post-Commit Actions

Example Script

Purpose Obtain the last log item from the working copy’s history (i.e. log) and copy it to the clipboard
Type Working copy
Argument Path to a working copy
#!/usr/bin/env bash

# Copies the contents of the last log item for the working copy to
# the clipboard.
#
# Usage:
#   CopyLogToClipboard working-copy
#
# Arguments:
#   $1 path to a working copy

svn log "$1" -r HEAD --limit 1 --verbose | pbcopy
		

$1 is used to reference the path of the working copy that was committed. It is supplied as the script’s single argument.

It is recommended that $1 be placed in quotation marks in order that the script functions correctly with paths containing space characters.