DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Accessing Subversion Repository Information In Ruby
require 'yaml' svn_info = YAML.load(`svn info /my/working/copy`) puts svn_info['URL'] #=> "svn://some-remote-repository.com/svn" puts svn_info['Revision'] #=> "133"
Should also work with svk info as well. Credit to htonl in #caboose for the YAML tip.






Comments
Snippets Manager replied on Sun, 2008/10/19 - 5:51pm
Snippets Manager replied on Mon, 2012/05/07 - 2:26pm
Snippets Manager replied on Wed, 2006/12/20 - 11:31pm
YAML.parse(`svnversion #{RAILS_ROOT}`).valueSnippets Manager replied on Mon, 2006/11/06 - 9:34am
require 'yaml' def get_svn_revision return nil if $RAILS_ENV == 'production' max = 0 entries = `svn info -R #{RAILS_ROOT}/*`.split(/\n\n/) entries.each do |entry| r = YAML.parse(entry)['Revision'].value.to_i max = r if r > max end return max end $SVN_REVISION = get_svn_revisionSnippets Manager replied on Wed, 2006/10/04 - 12:51pm