From: Michael Weller Date: 2004-10-08T22:38:51+09:00 Subject: Re: [ANN] svn_auto_add Jonathan Paisley wrote: > On Fri, 08 Oct 2004 21:31:21 +0900, Michael Weller wrote: > > >>I wrote a little script for svn users. It will detect any file added to >>a working copy which svn doesn't know about. In other words: it calls >>'svn add' for any newly added file. >>I thought I share it,just in case it might be helpful to somebody... (I >>actually don't think so because I'm a Nuby and everybody could write >>this script, but you never know :-) > > > [snip code] > > >>If somebody reads the script and thinks "Why is he doing this that way?" >>feel free to comment, I'm always open for improvements... > > > I wonder whether it might be simpler to just ask the command line tool > what files it doesn't know about (which will take into account the > relevant ignore settings for *.o, *.class etc). For example: > > $ svn status > ? somefile > ? otherfile > M modifiedfile > > By looking for lines that begin with a '?', we get precisely the list that > needs to be added. These lines could be turned into the appropriate 'svn > add' commands. > > One way (not particularly pleasant to look at) using ruby would be: > > $ svn status | ruby -ne 'puts $_[7..-2] if $_[0] == ??' > > to actually run the 'svn add' command you could use: > > $ svn status | ruby -e 'system("svn","add",$_[7..-2]) if $_[0] == ??' > > I think I would normally do it with a shell pipeline, since I find it > easier to compose the simpler steps than come up with the ruby script for > the whole thing: > > $ svn add `svn status | grep '^?' | cut -c8-` > (assuming no spaces in the names of the files to be added) > > Hope this makes sense! > Actually it makes a lot of sense... Much more than my approach :-(( But like I said I'm a nuby and happy that I got my script working my (much more complicated) way... Yes, shell pipes would be great :-(( Thanks for your input! Michael