import re


def _ParseCommitPosition(commit_message):
  """Parses a commit message for the commit position.

  Args:
    commit_message: The commit message as a string.

  Returns:
    An int if there is a commit position, or None otherwise."""
  match = re.search('^Cr-Commit-Position: [a-z/]+@{#([0-9]+)}$',
                    commit_message, re.MULTILINE)
  if match:
    return int(match.group(1))
  return None