Sha256: d57c694f8c9b6b47d6932148519f4dc01e598d544a94843c890258d0fd9dcdd8

Contents?: true

Size: 1.57 KB

Versions: 9

Compression:

Stored size: 1.57 KB

Contents

module Origen
  class Application
    # Keeps track of production released versions
    class VersionTracker
      STORAGE_FILE = "#{Origen.root}/.version_tracker"

      # Returns an array containing all Production release
      # tags since they started being tracked
      def versions
        storage[:versions] ||= []
      end

      # Adds a new version to the tracker
      def add_version(version)
        restore_to_latest
        versions << version
        save
        check_in
      end

      # Returns the persisted storage container (a Hash)
      def storage
        return @storage if @storage

        if File.exist?(STORAGE_FILE)
          File.open(STORAGE_FILE) do |f|
            @storage = Marshal.load(f)
          rescue
            @storage = {}
          end
        else
          @storage = {}
        end
      end

      # Save the persisted storage container to disk
      def save
        File.open(STORAGE_FILE, 'w') do |f|
          Marshal.dump(storage, f)
        end
      end

      # Check in the persisted storage container
      def check_in
        Origen.app.rc.checkin(STORAGE_FILE, force: true, unmanaged: true, comment: 'Recorded new version in the version tracker')
      end

      # Force the storage container to the latest checked in version
      def restore_to_latest
        @storage = nil
        # Check out the latest version of the storage, forcing to Trunk
        system "dssc co -get -force '#{STORAGE_FILE};Trunk:Latest'"
        system "dssc setselector 'Trunk' #{STORAGE_FILE}"
        `chmod 666 #{STORAGE_FILE}`
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
origen-0.60.17 lib/origen/application/version_tracker.rb
origen-0.60.16 lib/origen/application/version_tracker.rb
origen-0.60.14 lib/origen/application/version_tracker.rb
origen-0.60.13 lib/origen/application/version_tracker.rb
origen-0.60.12 lib/origen/application/version_tracker.rb
origen-0.60.11 lib/origen/application/version_tracker.rb
origen-0.60.10 lib/origen/application/version_tracker.rb
origen-0.60.9 lib/origen/application/version_tracker.rb
origen-0.60.8 lib/origen/application/version_tracker.rb