bugnum
author Smokey Ardisson <alqahira@ardisson.org>
Wed, 09 Jan 2013 00:39:16 -0500
changeset 52 d5a8a534399c0c24d45e073b7ea5f82b731b9f71
parent 29 5059128724adcfc4c762f962328d87440a0bc2f5
permissions -rwxr-xr-x
Missed refactoring: OBJDIR is superfluous now; just reference the default .dmg via BASEDIR plus objdir/arch/dist path directly.

#!/bin/sh
# Ensure that the commit message mentions a bug number or "no bug" and a 
# reviewer or superreviewer for checkins to Mozilla repos:
# [hooks]
# pretxncommit.bugnum = bugnum $HG_NODE
#
# 0 = true/success; hook must exit with 0 to allow the commit.
#
# See http://whereswalden.com/2009/01/10/how-to-not-commit-explicitly-unreviewed-changes-in-mercurial/
# for more shell hook ideas!

REPO=`hg showconfig paths.default 2>/dev/null`

# XXX TODO need to refactor the release-wrangling phrases into a single initial
# check, rather than duplicating them in both bug number and reviewer checks

echo $REPO | grep -q -i "\<mozilla-\|\<camino\|\<mxr"
result="$?"
if [ $result -eq 0 ]; then
  hg log -r $1 --template {desc} | grep -q -i "\<bug *[0-9]\|\<no bug\|\<Numbers for Camino\|\<Next release\|\<Added tag\|\<version bump"
  result="$?"
  if [ $result -eq 1 ]; then
    echo "\nError: No bug number mentioned in the commit message!\n"
    exit 1
  else
    hg log -r $1 --template {desc} | grep -q -i "\<r=\|\<sr=\|\<rs=\|\<r/sr=\|\<back out\|\<Numbers for Camino\|\<Next release\|\<Added tag\|\<version bump"
    result="$?"
    if [ $result -eq 1 ]; then
      # the a= check was added to compensate for an a-only transplant on a
      # Gecko relbranch; it should not normally be allowed.
      # XXXsa this won't actually work, because we'll be on a 
      # CAMINO_*_MINIBRANCH inside a Gecko repo :-(
      hg branch | grep -q "_RELBRANCH"
      result="$?"
      if [ $result -eq 0 ]; then
        hg log -r $1 --template {desc} | grep -q -i "\<a="
        result="$?"
        if [ $result -eq 1]; then
          echo "\nError: No reviewer, superreviewer, or approval mentioned in the commit message to a Gecko relbranch!\n"
          exit 1
        fi
      else
      #if [ $result -eq 1 ]; then
        hg log -r $1 --template {desc} | grep -q -i "\<try\:"
        result="$?"
        if [ $result -eq 1 ]; then
          echo "\nError: No reviewer or superreviewer mentioned in the commit message!\n"
          exit 1
        else
          echo "\n** Tryserver commit detected; be sure to 'hg rollback' after pushing to try! **\n"
        fi
      fi
    fi
  fi
fi