Page 1 of 1

Version control: automatic check-in to a repository

PostPosted: Sun Sep 28, 2008 12:51 pm
by vasudevaserver
Hi,
I am been experimenting with Hazel, and I can see how it could help a writer automatically check-in a file it to a subversion (or git, darcs, etc) repository after being saved. That would be a tremendous help.

Does somebody have an idea on how to implement that, say with subversion?

Priyadarshan

Re: Version control: automatic check-in to a repository

PostPosted: Mon Sep 29, 2008 5:33 pm
by Mr_Noodle
You would probably have to do a shell script. The rule would look like:

Code: Select all
If Date Modified is after Date Last Matched
Run shell script
    svn commit $1


What this does is if the file was changed since the last time the rule was matched, do an svn commit. Now there are some caveats here. Depending on the program saving the file and the type of file, Hazel may either wake up immediately upon saving and run the rule or it might take a couple minutes before Hazel wakes up. In the latter case, if you do multiple saves in that period, it will only commit after the last one when it wakes up. I don't know if that is acceptable or not.

If you need more clarification on this, just let me know. I also suggest doing this on a test setup just to make sure that it works the way you think.

Re: Version control: automatic check-in to a repository

PostPosted: Tue Sep 30, 2008 8:40 am
by vasudevaserver
Thank you, that is wonderful.

Right now everything works fine if I use the following shell code:
Code: Select all
svn commit $1 -m "constant text for commit"


There is any way I could add a token to the -m option of svn (inside the quotes), so that at the end I would have the equivalent of:

Code: Select all
svn commit $1 -m "[token_inserted_here]"


Thank you. Hazel is truly an excellent tool.

Priyadarshan

Re: Version control: automatic check-in to a repository

PostPosted: Wed Oct 01, 2008 1:23 pm
by Mr_Noodle
vasudevaserver wrote:There is any way I could add a token to the -m option of svn (inside the quotes)


Not sure if you are asking a question here but if so, the answer right now is no. Hazel only passes the filename in at the moment. What kind of information would you want to put there?

Re: Version control: automatic check-in to a repository

PostPosted: Thu Oct 02, 2008 7:46 am
by vasudevaserver
Mr_Noodle wrote:
vasudevaserver wrote:There is any way I could add a token to the -m option of svn (inside the quotes)


Not sure if you are asking a question here but if so, the answer right now is no. Hazel only passes the filename in at the moment. What kind of information would you want to put there?


One thing that would be quite useful is the Finder Comment field; Using Default Folder's dialog box at saving time, for example, a note that describe the new version could be added to the file's comment field, and Hazel could feed that automatically to Subversion.

The best probably would be being able to have a dialog box pop up requesting some text to be added to the shell script.

Even without those features though, Hazel is already very useful. Thank you!

Re: Version control: automatic check-in to a repository

PostPosted: Thu Oct 02, 2008 1:59 pm
by Mr_Noodle
You can do that using AppleScript. Here's one script someone posted to bring up the "Get Info" window in Finder where you can enter the comment: http://www.noodlesoft.com/forums/viewtopic.php?f=3&t=81

That may work for you as is or you can use it as a starting point.

Re: Version control: automatic check-in to a repository

PostPosted: Fri Oct 03, 2008 3:36 am
by vasudevaserver
Thank you very much.

Priyadarshan