You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Ethan Schlenker <et...@gamespot.com> on 2008/02/12 23:35:55 UTC

Adding a file to repos with a post commit hook?

Aloha,

I'm working on a way to automatically compress / minify our javascript  
files when committed, and want to run my current plan past the powers  
that be. I'm thinking that this flow may work:

- commit files including a .js file

- post-commit hook checks the files committed for normal .js files, if  
found:
     - grabs file, runs it through a minifier, and writes out  
a .min.js file in the same location as the original .js script
     - then adds? and commits the .min.js file

Or, I might be crazy (not sure if I can get the hook script to  
actually create/overwrite the existing file or do a add?/commit).    
Basically, I don't want to have our devs to remember to compress the  
files, and I want the compressed files saved in svn.

Does this seem cromulent? Or there a better way?  Any advice would be  
welcome, and if I get this working, I'd be happy to share the script.

-E

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

Re: Adding a file to repos with a post commit hook?

Posted by Andy Levy <an...@gmail.com>.
On Feb 12, 2008 7:17 PM, Ethan Schlenker <et...@gamespot.com> wrote:
> Both the normal js file and the compressed file will be in svn.  The
> compressed version will be also stored in svn so that our dev
> environment can use the compressed or the normal (to test if there are
> ever bugs with the compressed version).  Devs don't have to touch the
> compressed version as the post-commit hook would take care of updating
> the compressed file when they commit changes to a normal file.
>
> > and worry about compression nearer
> > deployment.  How do you deploy the javascript files?  Could you use
> > something like Ant (ant.apache.org) and trigger the compression then?
>
> Doing it as part of the deployment process, is an option, but I'd like
> the compressed file to be in svn as well so that the dev environments
> can easily use it for testing.  The more similar the live and dev
> enviroments are the better.

Why not use the same deployment process to update your development
environment as you use for the live environment (IOW, do the
"compression" when you put things out to the development environment
just like you would production)?

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

RE: Adding a file to repos with a post commit hook?

Posted by John Niven <jn...@bravurasolutions.com>.
> -----Original Message-----
> From: Wayne [mailto:wayne@zk.com]
> Sent: Wednesday, 13 February 2008 14:42
> To: John Niven
> Cc: Ethan Schlenker; users@subversion.tigris.org
> Subject: Re: Adding a file to repos with a post commit hook?
> 
> > I don't see why not (though I've limited experience with post-commit
> > hooks).  I can think of two possible approaches (disclaimer: I'm out
of
> > my SVN comfort-zone now, my experience with hook scripts is really
> > limited to ensuring there's a log message, but it is something I've
been
> > looking into recently):
> >
> > 1. If all your developers are using TortoiseSVN you could create a
> > client-side hook that regenerated the compressed js file(s), then
> > committed the new file(s).  This relies on all your team using
> > TortoiseSVN (and, by extension, Windows);
> > 2. Have a working copy on the SVN server, and a server-side hook to
> > regenerate the compressed file using new uncompressed file.  This is
> > almost certainly the preferred option.
> >
> > Hope this helps, and sorry I can't be more helpful
> > Cheers
> > John
> >
> >
> To me this method seems problematic. Developers are going to commit
> there changes and then forget to update there working copy. Then
they'll
> waste time trying to figure out why the new code they added doesn't
fix
> the problem only to find out it did but they are testing the old
version
> of the compressed files.
> I don't work with js but it would seem to me that you'd want something
> in place that make sure that the compressed version really matches the
> version the developer is looking at.

Agreed, that's why I'd be reluctant to store anything other than source
in SVN.  I still feel something like compressed javascript falls into
the "binary" category, i.e. it's rightfully a product of the build
process, and should only be generated when needed, i.e. before
deployment to a test server, etc.  I think *any* solution to this is
going to involve some problems at some point; it boils down to what the
original poster is comfortable with - and getting the developers to
update regularly may be easier than convincing the powers-that-be that
the development process may need revising ;-)

Cheers
John

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


Re: Adding a file to repos with a post commit hook?

Posted by Wayne <wa...@zk.com>.
John Niven wrote:
>> -----Original Message-----
>> From: Ethan Schlenker [mailto:ethans@gamespot.com]
>> Sent: Wednesday, 13 February 2008 13:17
>> To: users@subversion.tigris.org
>> Subject: Re: Adding a file to repos with a post commit hook?
>>
>> Hrm - Perhaps I didn't explain myself well enough :-)
>>     
>
> I think it's more likely that it's too hot for my poor little brain to
> work ;-)
>
>   
>> Both the normal js file and the compressed file will be in svn.  The
>> compressed version will be also stored in svn so that our dev
>> environment can use the compressed or the normal (to test if there are
>> ever bugs with the compressed version).  Devs don't have to touch the
>> compressed version as the post-commit hook would take care of updating
>> the compressed file when they commit changes to a normal file.
>>     
>
> Ah, OK.  No reason why you can't do this - I'd still prefer to keep only
> source (uncompressed) in SVN, and treat compressed as equivalent to a
> binary, i.e. a product of the build process, but that's personal
> preference.
>
>   
>>> and worry about compression nearer
>>> deployment.  How do you deploy the javascript files?  Could you use
>>> something like Ant (ant.apache.org) and trigger the compression
>>>       
> then?
>   
>> Doing it as part of the deployment process, is an option, but I'd like
>> the compressed file to be in svn as well so that the dev environments
>> can easily use it for testing.  The more similar the live and dev
>> enviroments are the better.
>>
>> I guess my question boils down to:  can a post-commit hook add/commit
>> a file in a repository?
>>     
>
> I don't see why not (though I've limited experience with post-commit
> hooks).  I can think of two possible approaches (disclaimer: I'm out of
> my SVN comfort-zone now, my experience with hook scripts is really
> limited to ensuring there's a log message, but it is something I've been
> looking into recently):
>
> 1. If all your developers are using TortoiseSVN you could create a
> client-side hook that regenerated the compressed js file(s), then
> committed the new file(s).  This relies on all your team using
> TortoiseSVN (and, by extension, Windows);
> 2. Have a working copy on the SVN server, and a server-side hook to
> regenerate the compressed file using new uncompressed file.  This is
> almost certainly the preferred option.
>
> Hope this helps, and sorry I can't be more helpful
> Cheers
> John
>
>   
To me this method seems problematic. Developers are going to commit 
there changes and then forget to update there working copy. Then they'll 
waste time trying to figure out why the new code they added doesn't fix 
the problem only to find out it did but they are testing the old version 
of the compressed files.
I don't work with js but it would seem to me that you'd want something 
in place that make sure that the compressed version really matches the 
version the developer is looking at.

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

RE: Re: Adding a file to repos with a post commit hook?

Posted by John Niven <jn...@bravurasolutions.com>.
> -----Original Message-----
> From: Ethan Schlenker [mailto:ethans@gamespot.com]
> Sent: Wednesday, 13 February 2008 13:17
> To: users@subversion.tigris.org
> Subject: Re: Adding a file to repos with a post commit hook?
> 
> Hrm - Perhaps I didn't explain myself well enough :-)

I think it's more likely that it's too hot for my poor little brain to
work ;-)

> 
> Both the normal js file and the compressed file will be in svn.  The
> compressed version will be also stored in svn so that our dev
> environment can use the compressed or the normal (to test if there are
> ever bugs with the compressed version).  Devs don't have to touch the
> compressed version as the post-commit hook would take care of updating
> the compressed file when they commit changes to a normal file.

Ah, OK.  No reason why you can't do this - I'd still prefer to keep only
source (uncompressed) in SVN, and treat compressed as equivalent to a
binary, i.e. a product of the build process, but that's personal
preference.

> 
> > and worry about compression nearer
> > deployment.  How do you deploy the javascript files?  Could you use
> > something like Ant (ant.apache.org) and trigger the compression
then?
> 
> Doing it as part of the deployment process, is an option, but I'd like
> the compressed file to be in svn as well so that the dev environments
> can easily use it for testing.  The more similar the live and dev
> enviroments are the better.
> 
> I guess my question boils down to:  can a post-commit hook add/commit
> a file in a repository?

I don't see why not (though I've limited experience with post-commit
hooks).  I can think of two possible approaches (disclaimer: I'm out of
my SVN comfort-zone now, my experience with hook scripts is really
limited to ensuring there's a log message, but it is something I've been
looking into recently):

1. If all your developers are using TortoiseSVN you could create a
client-side hook that regenerated the compressed js file(s), then
committed the new file(s).  This relies on all your team using
TortoiseSVN (and, by extension, Windows);
2. Have a working copy on the SVN server, and a server-side hook to
regenerate the compressed file using new uncompressed file.  This is
almost certainly the preferred option.

Hope this helps, and sorry I can't be more helpful
Cheers
John

> 
> > Anyway, just my $0.02 NZD.
> 
> Thanks!
> 
> -E
> 
> >
> >
> > Cheers
> > John
> >
> >>
> >> Does this seem cromulent? Or there a better way?  Any advice would
be
> >> welcome, and if I get this working, I'd be happy to share the
script.
> >>
> >> -E
> >>
> >>
---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> >> For additional commands, e-mail: users-help@subversion.tigris.org
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> > For additional commands, e-mail: users-help@subversion.tigris.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org


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


Re: Adding a file to repos with a post commit hook?

Posted by Blair Zajac <bl...@orcaware.com>.
Ethan Schlenker wrote:
> 
> On Feb 12, 2008, at 3:58 PM, John Niven wrote:
> I guess my question boils down to:  can a post-commit hook add/commit a 
> file in a repository?

Yes, you can in a post-commit.

FYI, you can't modify a transaction in the process of being committed, in a 
pre-commit script, so you can't add the compressed js file by modifying the 
transaction.

Regards,
Blair

--
Blair Zajac, Ph.D.
http://www.orcaware.com/svn/

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

Re: Adding a file to repos with a post commit hook?

Posted by Ethan Schlenker <et...@gamespot.com>.
On Feb 12, 2008, at 3:58 PM, John Niven wrote:

>> -----Original Message-----
>> From: Ethan Schlenker [mailto:ethans@gamespot.com]
>> Sent: Wednesday, 13 February 2008 12:36
>> To: users@subversion.tigris.org
>> Subject: Adding a file to repos with a post commit hook?
>>
>> Aloha,
>
> Kia ora!

Talofa!

>
>
>>
>> I'm working on a way to automatically compress / minify our  
>> javascript
>> files when committed, and want to run my current plan past the powers
>> that be. I'm thinking that this flow may work:
>>
>> - commit files including a .js file
>>
>> - post-commit hook checks the files committed for normal .js files,  
>> if
>> found:
>>     - grabs file, runs it through a minifier, and writes out
>> a .min.js file in the same location as the original .js script
>>     - then adds? and commits the .min.js file
>>
>> Or, I might be crazy (not sure if I can get the hook script to
>> actually create/overwrite the existing file or do a add?/commit).
>> Basically, I don't want to have our devs to remember to compress the
>> files, and I want the compressed files saved in svn.
>
> I'm unconvinced about this - I don't believe you do want the  
> compressed
> files saved in SVN.  The cost of storage per .js file is minimal, and
> subsequent changes will be stored as deltas.  The flipside is that  
> devs
> will then have to maintain a compressed file, which they probably  
> won't
> thank you for ;-)

Hrm - Perhaps I didn't explain myself well enough :-)

Both the normal js file and the compressed file will be in svn.  The  
compressed version will be also stored in svn so that our dev  
environment can use the compressed or the normal (to test if there are  
ever bugs with the compressed version).  Devs don't have to touch the  
compressed version as the post-commit hook would take care of updating  
the compressed file when they commit changes to a normal file.

> and worry about compression nearer
> deployment.  How do you deploy the javascript files?  Could you use
> something like Ant (ant.apache.org) and trigger the compression then?

Doing it as part of the deployment process, is an option, but I'd like  
the compressed file to be in svn as well so that the dev environments  
can easily use it for testing.  The more similar the live and dev  
enviroments are the better.

I guess my question boils down to:  can a post-commit hook add/commit  
a file in a repository?

> Anyway, just my $0.02 NZD.

Thanks!

-E

>
>
> Cheers
> John
>
>>
>> Does this seem cromulent? Or there a better way?  Any advice would be
>> welcome, and if I get this working, I'd be happy to share the script.
>>
>> -E
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
>> For additional commands, e-mail: users-help@subversion.tigris.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>


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

RE: Adding a file to repos with a post commit hook?

Posted by John Niven <jn...@bravurasolutions.com>.
> -----Original Message-----
> From: Ethan Schlenker [mailto:ethans@gamespot.com]
> Sent: Wednesday, 13 February 2008 12:36
> To: users@subversion.tigris.org
> Subject: Adding a file to repos with a post commit hook?
> 
> Aloha,

Kia ora!

> 
> I'm working on a way to automatically compress / minify our javascript
> files when committed, and want to run my current plan past the powers
> that be. I'm thinking that this flow may work:
> 
> - commit files including a .js file
> 
> - post-commit hook checks the files committed for normal .js files, if
> found:
>      - grabs file, runs it through a minifier, and writes out
> a .min.js file in the same location as the original .js script
>      - then adds? and commits the .min.js file
> 
> Or, I might be crazy (not sure if I can get the hook script to
> actually create/overwrite the existing file or do a add?/commit).
> Basically, I don't want to have our devs to remember to compress the
> files, and I want the compressed files saved in svn.

I'm unconvinced about this - I don't believe you do want the compressed
files saved in SVN.  The cost of storage per .js file is minimal, and
subsequent changes will be stored as deltas.  The flipside is that devs
will then have to maintain a compressed file, which they probably won't
thank you for ;-)

I appreciate that since you're dealing with javascript files you
possibly don't have a build process such as you'd find with, say, Java
or Dotnet, but my recommendation would be to keep genuine source, i.e.
uncompressed javascript files in SVN, and worry about compression nearer
deployment.  How do you deploy the javascript files?  Could you use
something like Ant (ant.apache.org) and trigger the compression then?

Anyway, just my $0.02 NZD.

Cheers
John

> 
> Does this seem cromulent? Or there a better way?  Any advice would be
> welcome, and if I get this working, I'd be happy to share the script.
> 
> -E
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org


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