You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Linda Halligan <lh...@bitpusher.com> on 2006/07/06 21:20:37 UTC

Hook script questions

Please don't beat me with the RTFM stick. I've searched for a few days now
and I'm not able to find an answer to my question.

 

I'm setting up a new subversion instance. It will contain a single
repository with several projects. One of those projects is going to be the
source for a tomcat based website. I want the website to get updated
automatically only when the "website" project is updated. Since I'm not a
coder I'm not entirely sure how to go about doing that.

 

Is it possible to write a post-commit script that will execute only if that
portion of the tree has been changed?

 

If someone could point me to an example of how this could be done I would be
eternally grateful.

 

 

-Linda


RE: Hook script questions

Posted by Linda Halligan <lh...@bitpusher.com>.

> -----Original Message-----
> From: Nick Thompson [mailto:nickthompson@agere.com]
> 
> Why use only one repository? If you have one repo per project,
> requirements such as yours become much easier to handle. It is also
> easier to maintain projects: Filtering a repo dump to remove bad
> commit data, archiving and taking a project offline, mirroring a
> specific project to another location, not taking all projects down if
> there is repo corruption or other repo down time, etc....
> 
> From the client side, there is not much apparent difference between
> one repo and many repos, but from an admin perspective, I can't see
> much to recommend having only one repo. Unless you like writing
> complex hook scripts ;-)
> 

Unfortunately it's not my decision to use a single repository. I do see the
benefits of using multiple repositories. And for future projects it will be
my recommendation to use separate repositories, but at this point what's
done is done.

-Linda



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Hook script questions

Posted by Nick Thompson <ni...@agere.com>.
On Thursday 06 July 2006 22:20, Linda Halligan wrote:
> Please don't beat me with the RTFM stick. I've searched for a few
> days now and I'm not able to find an answer to my question.
>
>
>
> I'm setting up a new subversion instance. It will contain a single
> repository with several projects. One of those projects is going to
> be the source for a tomcat based website. I want the website to get
> updated automatically only when the "website" project is updated.
> Since I'm not a coder I'm not entirely sure how to go about doing
> that.
>
>
>
> Is it possible to write a post-commit script that will execute only
> if that portion of the tree has been changed?
>
>
>
> If someone could point me to an example of how this could be done I
> would be eternally grateful.

Why use only one repository? If you have one repo per project, 
requirements such as yours become much easier to handle. It is also 
easier to maintain projects: Filtering a repo dump to remove bad 
commit data, archiving and taking a project offline, mirroring a 
specific project to another location, not taking all projects down if 
there is repo corruption or other repo down time, etc....

RE: Hook script questions

Posted by Linda Halligan <lh...@bitpusher.com>.
Ryan,

 This is exactly the help I was looking for. Thank you so much. 

 I didn't figure it would be difficult. But as I said I'm not a coder so
thinking in terms of scripts is difficult for me.


-Linda

-----Original Message-----
From: Ryan Schmidt [mailto:subversion-2006c@ryandesign.com] 

Hi Linda! This can definitely be done. The basic strategy for the  
post-commit hook would be:

* call "svnlook dirs-changed -r $REV $REPOS" (where $REV and $REPOS  
are the parameters passed into the script, as in the example post- 
commit hook) to get the list of directories that were changed by the  
commit.

* examine each line of the output with for example grep to determine  
if the path to your web site was affected

* if so, update a server-side working copy with "svn update"



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Hook script questions

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jul 6, 2006, at 23:20, Linda Halligan wrote:

> I’m setting up a new subversion instance. It will contain a single  
> repository with several projects. One of those projects is going to  
> be the source for a tomcat based website. I want the website to get  
> updated automatically only when the “website” project is updated.  
> Since I’m not a coder I’m not entirely sure how to go about doing  
> that.
>
>
>
> Is it possible to write a post-commit script that will execute only  
> if that portion of the tree has been changed?

Hi Linda! This can definitely be done. The basic strategy for the  
post-commit hook would be:

* call "svnlook dirs-changed -r $REV $REPOS" (where $REV and $REPOS  
are the parameters passed into the script, as in the example post- 
commit hook) to get the list of directories that were changed by the  
commit.

* examine each line of the output with for example grep to determine  
if the path to your web site was affected

* if so, update a server-side working copy with "svn update"


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org


Re: Hook script questions

Posted by Nico Kadel-Garcia <nk...@comcast.net>.
  ----- Original Message ----- 
  From: Linda Halligan 
  To: 'Nico Kadel-Garcia' ; users@subversion.tigris.org 
  Sent: Thursday, July 06, 2006 7:14 PM
  Subject: RE: Hook script questions


  Nico,

   

  I'm not sure what you mean by client in this context. The tomcat instance is actually running on the same server and I don't have control of what clients people will be using to update the repository. And I'm not actually going to be making changes to the site myself.

The Subversion working copy, whatever machine it resides on, uses an SVN client to do the update.

  I'd rather not use a cron job to check for changes since that will require a delay from commit to website update, and my spec sheet requires an "instant" update mechanism. So a post commit script seemed like the right answer.

Ahh. That explains your need: in this case, where the working copy resides on the same machine, a post-commit hook seems very reasonable. I've seen people here looking for ways to push updates to every copy on every other machine, which gets a lot more awkward to do.

RE: Hook script questions

Posted by Linda Halligan <lh...@bitpusher.com>.
Nico,

 

I'm not sure what you mean by client in this context. The tomcat instance is
actually running on the same server and I don't have control of what clients
people will be using to update the repository. And I'm not actually going to
be making changes to the site myself.

 

I'd rather not use a cron job to check for changes since that will require a
delay from commit to website update, and my spec sheet requires an "instant"
update mechanism. So a post commit script seemed like the right answer.

 

Thanks for the help.

 

-Linda

 

  _____  

From: Nico Kadel-Garcia [mailto:nkadel@comcast.net] 

Now, now, no sticks on newbies (unless they're into it: I have some SCA
friends). Post-commit is really a server side command: if the clients are
known, you could use an SSH or other remote access tool to push an update to
it.

 

But instead, if I may suggest, why not have the client simply run a query on
a cron-job basis to see if there have been any changes in that project? Use
"svn info -r HEAD /workingcopy" and parse out it's URI and revision number.
If there is a difference between them, pull the update instead of pushing.
That's how I've done it for a website under subversion.


Re: Hook script questions

Posted by Nico Kadel-Garcia <nk...@comcast.net>.
----- Original Message ----- 
  From: Linda Halligan 
  To: users@subversion.tigris.org 
  Sent: Thursday, July 06, 2006 5:20 PM
  Subject: Hook script questions


  Please don't beat me with the RTFM stick. I've searched for a few days now and I'm not able to find an answer to my question.

   

  I'm setting up a new subversion instance. It will contain a single repository with several projects. One of those projects is going to be the source for a tomcat based website. I want the website to get updated automatically only when the "website" project is updated. Since I'm not a coder I'm not entirely sure how to go about doing that.

   

  Is it possible to write a post-commit script that will execute only if that portion of the tree has been changed?

   

  If someone could point me to an example of how this could be done I would be eternally grateful.

   

   

  -Linda



Now, now, no sticks on newbies (unless they're into it: I have some SCA friends). Post-commit is really a server side command: if the clients are known, you could use an SSH or other remote access tool to push an update to it.



But instead, if I may suggest, why not have the client simply run a query on a cron-job basis to see if there have been any changes in that project? Use "svn info -r HEAD /workingcopy" and parse out it's URI and revision number. If there is a difference between them, pull the update instead of pushing. That's how I've done it for a website under subversion.