@@ -1,10 +1,34 | |||||
|
1 | require 'rexml/document' | |||
|
2 | ||||
1 | module Redmine |
|
3 | module Redmine | |
2 | module VERSION #:nodoc: |
|
4 | module VERSION #:nodoc: | |
3 | MAJOR = 0 |
|
5 | MAJOR = 0 | |
4 | MINOR = 5 |
|
6 | MINOR = 5 | |
5 | TINY = 1 |
|
7 | TINY = 1 | |
6 |
|
8 | |||
7 | STRING= [MAJOR, MINOR, TINY].join('.') |
|
9 | def self.revision | |
|
10 | revision = nil | |||
|
11 | entries_path = "#{RAILS_ROOT}/.svn/entries" | |||
|
12 | if File.readable?(entries_path) | |||
|
13 | begin | |||
|
14 | f = File.open(entries_path, 'r') | |||
|
15 | entries = f.read | |||
|
16 | f.close | |||
|
17 | if entries.match(%r{^\d+}) | |||
|
18 | revision = $1.to_i if entries.match(%r{^\d+\s+dir\s+(\d+)\s}) | |||
|
19 | else | |||
|
20 | xml = REXML::Document.new(entries) | |||
|
21 | revision = xml.elements['wc-entries'].elements[1].attributes['revision'].to_i | |||
|
22 | end | |||
|
23 | rescue | |||
|
24 | # Could not find the current revision | |||
|
25 | end | |||
|
26 | end | |||
|
27 | revision | |||
|
28 | end | |||
|
29 | ||||
|
30 | REVISION = self.revision | |||
|
31 | STRING = [MAJOR, MINOR, TINY, REVISION].compact.join('.') | |||
8 |
|
32 | |||
9 | def self.to_s; STRING end |
|
33 | def self.to_s; STRING end | |
10 | end |
|
34 | end |
General Comments 0
You need to be logged in to leave comments.
Login now