#! /bin/sh
# $Id: //guest/jeff_bowles/perforce-triggers/Jobs.sh#1 $
# Copyright (c) 1999 Softweyr LLC. All rights reserved.
#
# Redistribution and use in source form, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notices,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# 3. The name of Softweyr LLC and it contributors may not be used to endorse
# or promote products derived from this software without specific prior
# written permission.
#
# This software is provided by Softweyr LLC and contributors ``AS IS'' and
# any express or implied warranties, including, but not limited to, the
# implied warranties of merchantability and fitness for a particular purpose
# are DISCLAIMED. In no event shall Softweyr LLC or
# contributors be liable for any direct, indirect, incidental, special,
# exemplary, or consequential damages (including, but not limited to,
# procurement of substitute goods or services; loss of use, data, or
# profits; or business interruption) however caused and on any theory of
# liability, whether in contract, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# -----------------------------------------------------------------------------
#
# Require Perforce commits to have a job number associated with every change.
#
# Note that the p4 server collects the output from this program and shows it
# to the client user if the program returns non-zero, indicating failure.
# Success is silent to avoid nattering at the user unnecessarily.
#
# args:
#
# $1 - the changelist being submitted
#
P4PORT=xxxx:1666; export P4PORT
change=$1
fixes=`p4 fixes -c $change | wc -l`
if [ "$fixes" -gt 0 ] ; then
#echo "Submitting change $change for $fixes problems"
exit 0
else
echo "Change $change doesn't fix anything"
exit 1
fi