version.rb 935 Bytes
Newer Older
1 2
require 'rexml/document'

3
module Redmine
maeda's avatar
maeda committed
4 5
  # @private
  module VERSION
jplang's avatar
jplang committed
6 7
    MAJOR = 4
    MINOR = 0
jplang's avatar
jplang committed
8
    TINY  = 1
9

10 11 12 13 14
    # Branch values:
    # * official release: nil
    # * stable branch:    stable
    # * trunk:            devel
    BRANCH = 'devel'
15

16
    # Retrieves the revision from the working copy
17
    def self.revision
18
      if File.directory?(File.join(Rails.root, '.svn'))
19
        begin
20
          path = Redmine::Scm::Adapters::AbstractAdapter.shell_quote(Rails.root.to_s)
21
          if `#{Redmine::Scm::Adapters::SubversionAdapter.client_command} info --xml #{path}` =~ /revision="(\d+)"/
22
            return $1.to_i
23 24 25 26 27
          end
        rescue
          # Could not find the current revision
        end
      end
28
      nil
29 30 31
    end

    REVISION = self.revision
32 33
    ARRAY    = [MAJOR, MINOR, TINY, BRANCH, REVISION].compact
    STRING   = ARRAY.join('.')
34

35
    def self.to_a; ARRAY  end
36
    def self.to_s; STRING end
37 38
  end
end