The Artima Developer Community
Sponsored Link

Java Buzz Forum
More Fun Little Scripts

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
More Fun Little Scripts Posted: Mar 16, 2005 2:42 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: More Fun Little Scripts
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

What the heck, another useful little script. This one is called svnrepo which does the simple thing of providing convenient svn repository munging:

#!/usr/bin/env ruby

entries = File.open("#{ENV['PWD']}/.svn/entries")
begin
  escape = callcc do |escape|
    entries.each_line do |line|
      if line =~ /\s+url="(.+)"/
        repo = $1
        if ARGV.length > 0
          arg = ARGV[0]
          arg = arg[1, arg.length].to_i
          repo = repo.reverse
          arg.times do |i| 
            repo = repo[repo.index("/") + 1 , repo.length]
          end
          puts repo.reverse
        else
          puts repo
        end
        escape.call
      end
    end
  end
rescue
  puts "You backed up too far into the repo string"
  exit -1
ensure
  entries.close
end

The reason for this instead of just svn info | grep URL | cut -f 2 -d ' ' is backing up directories in the svn repo (svnrepo -1 or svnrepo -2 to back up one directory, or two, respectively):

brianm@kite:~/src/jdbi$ svnrepo
svn+ssh://jdbi.codehaus.org/home/projects/jdbi/scm/trunk
brianm@kite:~/src/jdbi$ svnrepo -2
svn+ssh://jdbi.codehaus.org/home/projects/jdbi
brianm@kite:~/src/jdbi$ 

so you can do niceties like the tag-release.sh script:

svn cp $(svnrepo) $(svnrepo -1)/tags/release-$(date +%Y-%m-%d)

It also has a fun gratuitous use of a continuation as a premature optimization ;-)

Read: More Fun Little Scripts

Topic: Frameworks are leading indicators for programming languages Previous Topic   Next Topic Topic: Containers and Webapps

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use