i m using subversion (Xcode) to commit my files , i would like to开发者_Go百科 add my svn info on all my file headers - please let me know is any other script available to do this ?
Like
Node Kind: directory
Schedule: normal
Last Changed Author: karthikeyan
Last Changed Rev: 9
Last Changed Date: 2011-06-21 23:55:20 +0530 (Tue, 21 Jun 2011)
#import "TestController.h"
@implementation TestController
Shell-fu to the rescue...
I don't know what 'Node Kind' and 'Schedule' are, but do the following:
Put the following in a shell script, call it insert_header.sh
for argument's sake:
#!/bin/bash
FILE=$1
sed '1s:^:\
:
1i\
Node Kind: directory
1i\
Schedule: normal
1i\
Last Changed Author: $Author$
1i\
Last Changed Rev: $Rev$
1i\
Last Changed Date: $LastChangedDate$
' $FILE > $FILE.somerandombackupextension
mv $FILE.somerandombackupextension $FILE
Open a Terminal session.
Make the file executable with chmod +x insert_header.sh
and put it in your PATH, or run it with its relative path (see below).
Then, run the following command in your source checkout directory (e.g. if you want to change files with extension .cpp):
find . -name \*.cpp -exec insert_header.sh {} \; -exec svn propset svn:keywords "Author Rev LastChangedDate" {} \;
Run svn status
, and expect to see all the changed files with the following 'MM' status code:
MM path/to/file1.cpp
MM path/to/file2.cpp
If you don't like the changes, revert with svn revert -R .
, otherwise svn commit -m "+1 for opyate ;-)"
PS I tried it with a dummy project, and it ended up looking like this, which is normal:
Node Kind: directory
Schedule: normal
Last Changed Author: $Author: opyate $
Last Changed Rev: $Rev: 2 $
Last Changed Date: $LastChangedDate: 2011-06-30 23:20:33 +0100 (Thu, 30 Jun 2011) $
...the rest of my file
SVN Keywords should do exactly what you want
精彩评论