aboutsummaryrefslogblamecommitdiff
path: root/sh/eci.sh
blob: 0d21690bec8400617a7d0d168913128ca76cd656 (plain) (tree)
1
2
3
4
5
6
7
8
          
 
                                
 
                             
 

                                                                   


               
                           

                                
                                      



                                   

                            




                                   
                    
 
                  
 

                                              
         
 
                           
 
                                              
 
                    
 
                                              
 
                                        
                                
                        


               

                                                                                                                      
 
                                                                           
                                                                                           
                                                 
 
                
                                                                                                                                      
 
                                                             
 
                                  
 
                                
#!/bin/zsh

PROJECT_PATH="${HOME}/dev/espik"

TMPFILE="/tmp/.eci-${RANDOM}"

if [ ! -e ${PROJECT_PATH} ]; then
	echo "PROJECT_PATH defined (${PROJECT_PATH}) doesn't exist"
	exit -1
fi

if [ -z "${EDITOR}" ]; then
	echo "EDITOR is not set"
	exit -1
elif [ ! -e $(which ${EDITOR}) ]; then
	echo "EDITOR doesn't exist"
	exit -1
fi

touch ${TMPFILE}
if [ ! -e ${TMPFILE} ]; then
	echo "Cannot write to /tmp"
	echo "Check perms ;)"
	exit -1
fi

chmod 600 ${TMPFILE}

cd ${PROJECT_PATH}

echo "
--This line and thoses under will be ignored--
$(svn st)

$(svn diff)" >> ${TMPFILE} 

SUM_ORI=$(cksum ${TMPFILE} | awk '{print $1}')

${EDITOR} ${TMPFILE}

SUM_NEW=$(cksum ${TMPFILE} | awk '{print $1}')

if [ "${SUM_ORI}" = "${SUM_NEW}" ]; then
	echo "Enter something !"
	rm -f ${TMPFILE}
	exit -1
fi

DELCOMMENTFROM=$(grep -n -- '--This line and thoses under will be ignored--' ${TMPFILE} | head -n 1 | cut -d ':' -f 1)
head -n $(($DELCOMMENTFROM-1)) ${TMPFILE} > ${TMPFILE}.send

echo -e " $(date "+%d %b %Y %X");\t${GIT_AUTHOR_NAME} <${GIT_AUTHOR_EMAIL}>
\t\t\tfrom $(whoami) @ $(if [ `uname -o` = "Cygwin" ]; then hostname; else hostname -f; fi)
$(cat ${TMPFILE}.send | sed -r 's/(.*)/\t* \1/g')

\tFiles Changes:
$(svn st | grep -v '^?' | sed -r 's/^D(.*)/-\1/g' | sed -r 's/^M(.*)/@\1/g' | sed -r 's/^A(.*)/+\1/g' | sed -r 's/(.*)/\t\1/g' | sort)

$(cat ${PROJECT_PATH}/ChangeLog)" > ${PROJECT_PATH}/ChangeLog

svn ci -m "$(cat ${TMPFILE}.send)"

rm -f ${TMPFILE} ${TMPFILE}.send