Version control: automatic check-in to a repository

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

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
vasudevaserver
 
Posts: 4
Joined: Sun Sep 28, 2008 12:44 pm

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.
Mr_Noodle
Site Admin
 
Posts: 8571
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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
vasudevaserver
 
Posts: 4
Joined: Sun Sep 28, 2008 12:44 pm

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?
Mr_Noodle
Site Admin
 
Posts: 8571
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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!
vasudevaserver
 
Posts: 4
Joined: Sun Sep 28, 2008 12:44 pm

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.
Mr_Noodle
Site Admin
 
Posts: 8571
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thank you very much.

Priyadarshan
vasudevaserver
 
Posts: 4
Joined: Sun Sep 28, 2008 12:44 pm


Return to Tips & Tricks - DO NOT POST QUESTIONS