[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: How can I parse the output of "svn update"? [SOLVED]

From: Daevid Vincent <daevid_at_daevid.com>
Date: Mon, 11 Aug 2008 18:02:38 -0700

Well, since I got zero responses from this list, I'll post the solution that
the gracious people on the SVLUG list provided:

 

#!/bin/sh

 

#

# Original idea and modifications: Daevid Vincent [daevid_at_daevid.com]

# The meat and potatoes: Jeremiah Wuenschel [jeremiah.wuenschel_at_gmail.com]

#

# version 2008-08-11 5:50pm

#

 

if [ $USER != "dev" ]

then

    echo "You must run this as user 'dev'."

    exit 1

fi

 

CURR=`pwd`

 

cd /home/prod

 

svn update | awk '

    BEGIN {need_update=0;}

    /update\.sql/{need_update=1;}

    {print}

    END {if(need_update) {

            printf "'$(echo -e "\033[1;31m")'"

            print ""

            print "########################################################"

            print " DON\047T FORGET TO RUN THE site/data/sql/update.sql "

                        print " sudo mysql prod
"

            print "########################################################"

            printf "'$(echo -e "\033[0m")'"

    }}

'

 

cd $CURR

 

I've put it also on my website along with other snippets under "Subversion
Flagged Update"

http://daevid.com/content/examples/snippets.php

 

From: Daevid Vincent [mailto:daevid_at_daevid.com]
Sent: Friday, August 08, 2008 2:22 PM
To: users_at_subversion.tigris.org
Subject: How can I parse the output of "svn update"?

 

Can someone show me a good way to parse the output of "svn update" via a
script (bash or php)? Or does anyone have a script that does something like
this already?

 

There's a lot of files whizzing by and it's not always easy to spot if there
is an update.sql file listed. I want to append a comment to the screen that
says "Hey, don't forget to run the update.sql commands or your database will
be whack." It would also be nice if I could change the color (via ANSI
escape sequences) for that line too.

 

I'm thinking something like this:

 

dev_at_devbox ~ $ svnu

U site/batch/index_user.php

U site/apps/frontend/lib/myLoginValidator.class.php

U site/apps/frontend/modules/sidebar/templates/_signin.php

U site/apps/frontend/modules/content/actions/actions.class.php

U site/apps/frontend/modules/content/config/view.yml

U site/apps/frontend/templates/layout.php

U site/data/sql/update.sql

U site/apps/frontend/modules/foo/config/bar.yml

U site/apps/frontend/modules/foo/bar.php

 

########################################################

   DON'T FORGET TO RUN THE site/data/sql/update.sql

########################################################

 

We're already in the habit of typing "svnu" as an alias to "svn update", so
I figure I can just re-use that name J.
Received on 2008-08-12 03:03:58 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.