[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: Tue, 12 Aug 2008 14:03:05 -0700

Touché

You are correct in that YOU were a kind soul to help and for that I am
grateful. Since your email didn't have any indication in the subject that
this was from the subversion list, I mistakenly thought you were from the
svlug list for some reason.

And while I sort of see your point, I think it's a little short sighted (no
offense intended). The question I posed *is* related to subversion AND shell
scripting... (Most tools do not exist in a vacuum and in fact all the
pre/post commit scripts require a scripting language to use them)

This is a problem that I would think is not unique to our development
environment, and one that would be nice if subversion had built in hooks to
handle somehow. I think it is fairly common for developers to have to update
a SQL database or do some other task (such as clear a Symfony cache if the
routing.yml file changes), or any number of other "trigger this
message/script if this file is changed" scenarios.

There are all kinds of pre-commit and post-commit scripts, but this pain
falls in a different realm -- that of "svn update", for which there doesn't
seem to be any kind of hooks (of course because SVN resides server-side and
'update' is client-side). However, one still needs to install the subversion
package on any *nix box and therefore the solution/scripts could be included
as wrappers or triggers to the "svn update" command. I'm sure tigris could
work some magic within the ~/.subversion directory to trigger an external
script on update.

Anyways... thanks for your reply and I hope that my posting will help some
other developer trying to accomplish this task.

http://daevid.com

-----Original Message-----
From: David Weintraub [mailto:qazwart_at_gmail.com]
Sent: Tuesday, August 12, 2008 7:26 AM
To: Daevid Vincent
Cc: users_at_subversion.tigris.org
Subject: Re: How can I parse the output of "svn update"? [SOLVED]

On Mon, Aug 11, 2008 at 9:02 PM, Daevid Vincent <daevid_at_daevid.com> wrote:
> Well, since I got zero responses from this list, I'll post the solution
that
> the gracious people on the SVLUG list provided:

Not entirely true:

I sent you a private response which included an outline of a shell
script that would do what you want.

I didn't send the response to the list because it had nothing to do
with Subversion. The question you asked had more to do with shell
scripting or in your case AWK.

--
David Weintraub
qazwart_at_gmail.com
On Mon, Aug 11, 2008 at 9:02 PM, Daevid Vincent <daevid_at_daevid.com> wrote:
> 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.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-08-12 23:04:27 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.