以前有个项目非得用到Clear Case,但又不提供好用点的命令,每次check out/in都得敲一大堆命令,容易出错不说,对我等懒人简直是无法忍受.
具有简单的check in/out, list, copy source等功能,因为Clear Case比较特殊,运行的时候自己创建一个新进程,所以这里用到了输入重定向.
脚本实例
------------
#!/bin/ksh
PRGN=`basename $0`
#AUTHOR : Ricky Wu
#Function : Clear Case Tool for * Branch
#Get Branch
userbranch=`echo ${LOGNAME} | cut -c 4-7`****
#Change like below
echo "Your Branch is:"$userbranch
fun=$1
loc=$2
filename=$3
version=$4
case $fun in
co)
;;
unco)
;;
ci)
;;
lsco)
;;
get)
;;
bk)
;;
sv)
;;
merge)
;;
*)
echo "Invalid Function!"
exit
;;
esac
cleartool setview $userbranch << !
quit()
{
exit $1
}
cd /vobs/source/
if [ ! -d /vobs/source/$loc ]
then
echo "Source Location Dose Not Exsist!"
quit 1
fi
cd /vobs/source/$loc
if [ ${fun} == "lsco" ]
then
cleartool ${fun}
quit 1
fi
if [ ! -f /vobs/source/$loc/${filename} ]
then
echo "File [/vobs/source/$loc/${filename}] Not Exist,Please Check!"
quit 1
fi
if [ ${fun} == "co" ]
then
# Check out source code and write comment.
echo "." | cleartool ${fun} ${filename}
if [ -f ${HOME}/${filename} ]
then
echo "********************************"
echo "Notice: ${filename} already exsits!"
echo "Copy ${filename} as ${filename}.bak.$$"
echo "********************************"
cp ${HOME}/${filename} ${HOME}/${filename}.bak.$$
cp /vobs/source/$loc/${filename} ${HOME}/${filename}
echo "Checked Out File: [${filename}]"
else
cp /vobs/source/$loc/${filename} ${HOME}
echo "Checked Out File: [${filename}]"
fi
chmod 755 ${HOME}/${filename}
fi
if [ ${fun} == "unco" ]
then
echo "N" | cleartool ${fun} ${filename}
fi
if [ ${fun} == "ci" ]
then
if [ ! -f ${HOME}/${filename} ]
then
echo "Check In's File Dose Not Exsist!"
quit 1
fi
tt.sh ${HOME}/${filename}
cp ${HOME}/${filename} /vobs/source/$loc/
if [ $? -ne 0 ]
then
echo "Checkin cp File Error"
quit 1
fi
cleartool ${fun} ${filename}
fi
if [ ${fun} == "get" ]
then
# Get One of the old version
if [ ! -f /vobs/source/$loc/${getname} ]
then
echo "This Version Not Exsist!"
quit 1
fi
cp /vobs/source/$loc/${getname} ${HOME}/${getver}
echo "Get File: [${getname}]"
chmod 755 ${HOME}/${getver}
fi
if [ ${fun} == "bk" ]
then
# Get out the source code.
if [ -f ${HOME}/${filename} ]
then
else
fi
fi
if [ ${fun} == "sv" ]
then
cd /vobs/source/$loc/
echo 'ls -l ${filename}' |cleartool
fi
if [ ${fun} == "merge" ]
then
# Check out the source code then merge
echo "." | cleartool co ${filename}
cleartool ${fun} -to ${filename} -version /main/LATEST
if [ -f ${HOME}/${filename} ]
then
...
else
...
fi
echo "Then make sure use [${HOME}/${filename}] Check In!"
fi
!
exit $?