SVN Pre Commit Hook : Sanitize your Code!

Posted by: Admin  :  Category: Web Hosting

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

Hello,

Dealing with several different development environments can be tricky. With SVN specifically, it is ideal to have some “pre-flight” checks in order to make sure some basic standards have been followed.

Some of the things you would want to check might be :

– Does the code generate a fatal PHP error?
– Is there any syntax errors?
– Has valid commit messages been attached to the code commit?

I thought I’d share our pre-commit hook in one of our SVN code repositories in order to let you utilize and perhaps expand on it to include many more checks. Additional checks that may be specific to your code environment might benefit you. Feel free to share if improvements are made!

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

#!/bin/bash
# pre-commit hooks
# www.stardothosting.com

REPOS="$  1"
TXN="$  2"

PHP="/usr/bin/php"
SVNLOOK="/usr/bin/svnlook"
AWK="/usr/bin/awk"
GREP="/bin/egrep"
SED="/bin/sed"

# Make sure that the commit message is not empty
SVNLOOKOK=1
$  SVNLOOK log -t "$  TXN" "$  REPOS" | grep "[a-zA-Z0-9]" > /dev/null || SVNLOOKOK=0

if [ $  SVNLOOKOK = 0 ]; then
        echo -e "Empty commit messages are not allowed. Please provide a descriptive comment when committing code." 1>&2
        exit 1
fi

# Make sure the commit message is more than 5 characters long.
LOGMSG=$  ($  SVNLOOK log -t "$  TXN" "$  REPOS" | grep [a-zA-Z0-9] | wc -c)

if [ "$  LOGMSG" -le 5 ]; then
        echo -e "Please provide a verbose comment when committing changes." 1>&2
        exit 1
fi


# Check for PHP parse errors
CHANGED=`$  SVNLOOK changed -t "$  TXN" "$  REPOS" | $  GREP "^[U|A]" | $  AWK '{print $  2}' | $  GREP \.php$  `

for FILE in $  CHANGED
do
    MESSAGE=`$  SVNLOOK cat -t "$  TXN" "$  REPOS" "$  FILE" | $  PHP -l`
    if [ $  ? -ne 0 ]
    then
        echo 1>&2
        echo "-----------------------------------" 1>&2
        echo "PHP error in: $  FILE:" 1>&2
        echo `echo "$  MESSAGE" | $  SED "s| -| $  FILE|g"` 1>&2
        echo "-----------------------------------" 1>&2
        exit 1
    fi
done

exit 0

DiggTwitterRedditDeliciousShare

*.hosting*.hosting

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

The Best Web Hosting Tips Before You Commit

Posted by: Admin  :  Category: Web Hosting

Want to make money online? You will need a website to get this done. In fact, whether you are doing Internet Marketing, or something else, a website is becoming something everyone needs. With the amount of living we do online, having a website only seems natural. A hosting provider that we can trust is not as easy to find as you would think. It can be very confusing! There are many available which makes it even harder! How do you know which one is right?
Find Articles, Free Articles Directory | Web Hosting Articles

[MISCS] I WILL COMMIT SUICIDE

Posted by: Admin  :  Category: Apache

(*)

I WILL COMMIT SUICIDE

Dear the readers of Apachenews.org.

Editor, Tetsuya Kitahata, will commit suicide in a few days. (maybe today) — have enough medicine to execute. I really appreciate your reading in the past and thanks to you.

I was really disappointed by the Apache’s bureaucratism. and I got a lot of fraud. So tired in Life.

Hope you will find the right place to do your business of own ,and collaborate with special guys.

Sayo-nara

— Tetsuya Kitahata — mailto:kitahata@99.alumni.u-tokyo.ac.jp

[ Category : Apache Software Foundation ] PDFXML_RSS

Apache News Online

[MISCS] Could not COMMIT SUICIDE

Posted by: Admin  :  Category: Apache

(*)

Cound not COMMIT SUICIDE

Dear the readers of Apachenews.org.

I am open to network with all professionals across various disciplines as it is my strong belief that we are all citizens of the world and we can all learn/gain from each other in a mutually beneficial manner. Every new person met has the potential to be a true #MASTER MIND#, you will only discover this by getting out and interacting

Please relieve that I, Tetsuya Kitahata, could not do the suicide because of the lack of money for alcohol. So many responses were there that I received. Thank you to ALL. Yours,

— Tetsuya Kitahata — mailto:kitahata@99.alumni.u-tokyo.ac.jp — http://www.linkedin.com/in/tetsuya


Appreciate




[ Category : Apache Software Foundation ] PDFXML_RSS

Apache News Online