SVN: Useful bash commands

nadeem.shabir | | Saturday, October 18th, 2008

Here’s a couple of useful bash commands I’ve been using recently when working with Subversion:

The first helps me with an annoyance I have with externals. Normally doing a “svn st –ignore-externals” still lists all the externals even though I’m not actually interesting in seeing them when I want to know what I’ve changed locally. For example in the output below I only really want to know that I’ve changed ‘development-tenants.xml’, i’m not really interested in the rest.

Nadeems-Computer:zephyr-trunk nadeemshabir$ svn st --ignore externals
X      lib/arc
X      lib/moriarty
X      lib/simpleSAMLphp
X      3rdPartyDevelopmentTools/svnant-1.0.0
X      3rdPartyDevelopmentTools/PHPUnit
X      3rdPartyDevelopmentTools/selenium-server-1.0-beta-1
X      3rdPartyDevelopmentTools/selenium-core-0.8.3
M      developmentdata/development-tenants.xml

To address this the first command is an alias I’ve created that shows me all the files that I’ve changed/added/removed locally but specifically doesn’t list anything related to any externals

alias whatschanged='svn st --ignore-externals | grep -v "^X "'

The second bash command deals with the fact that I often have a large number of files I want to add to subversion all at once. This command takes all un-added files and adds them to subversion …

svn st | grep '^? ' | awk '{ print $2 }' | xargs svn add

Hope you find them useful.

, ,

Cool Bash One-Liner: SVN add all unadded files

nadeem.shabir | | Sunday, February 3rd, 2008
  1.  
  2. svn st | grep "^? " | awk ‘{ print $2 }’ | xargs svn add
  3.  
,

Cool Bash One-Liner: Post files to Platform Store

nadeem.shabir | | Sunday, February 3rd, 2008

As part of some small prototyping activity I had to convert a whole load of data into rdf. My problem was that the files I had generated were scattered around in a very hierarchical directory structure, but all I wanted to do was find them and most them to a platform store. I really didn’t want to have to post them one at time manually. I knew I could do it using a bash script but my scripting was a bit rusty … so I asked Rob, he showed me how to do this …

  1.  
  2. find . -name "*-issue.xml.rdf" | sed -e ’s!^\./\([0-9]*-issue.xml.rdf\)!curl -v -d @\1  -H content-type:application/rdf+xml http://api.talis.com/stores/kiyanwang-dev1/meta!’ | bash
  3.  

Cool, huh? :)

For the un-initiated, the find locates all the files I want to post which in my case ended with -issue.xml.rdf. The sed search and replace matches the filename, and then replaces it with a curl command, inserting the filename as a parameter @\1. Finally the generated curl command is piped to bash which executes each generated line.
.

,

Powered by WordPress | Theme by Roy Tanck