Sha256: 838181a5fb366863678d05ceca4670af0fbd51a8bcc7385d4550013be336e227

Contents?: true

Size: 1.97 KB

Versions: 31

Compression:

Stored size: 1.97 KB

Contents

require 'autobuild/subcommand'
require 'autobuild/importer'

module Autobuild
    class SVN < Importer
	# Creates an importer which gets the source for the Subversion URL +source+.
	# The following options are allowed:
	# [:svnup] options to give to 'svn up'
	# [:svnco] options to give to 'svn co'
	#
	# This importer uses the 'svn' tool to perform the import. It defaults
	# to 'svn' and can be configured by doing 
	#   Autobuild.programs['svn'] = 'my_svn_tool'
        def initialize(source, options = {})
            @source = [*source].join("/")
            @program    = Autobuild.tool('svn')
            @options_up = [*options[:svnup]]
            @options_co = [*options[:svnco]]
            super(options)
        end

        private

        def update(package) # :nodoc:
            Dir.chdir(package.srcdir) {
		old_lang, ENV['LC_ALL'] = ENV['LC_ALL'], 'C'
		svninfo = IO.popen("svn info") { |io| io.readlines }
		ENV['LC_ALL'] = old_lang
		unless url = svninfo.grep(/^URL: /).first
		    if svninfo.grep(/is not a working copy/).empty?
			raise ConfigException, "#{package.srcdir} is not a Subversion working copy"
		    else
			raise ConfigException, "Bug: cannot get SVN information for #{package.srcdir}"
		    end
		end
		url.chomp =~ /URL: (.+)/
		source = $1
		if source != @source
		    raise ConfigException, "current checkout found at #{package.srcdir} is from #{source}, was expecting #{@source}"
		end
                Subprocess.run(package, :import, @program, 'up', "--non-interactive", *@options_up)
            }
        end

        def checkout(package) # :nodoc:
            options = [ @program, 'co', "--non-interactive" ] + @options_co + [ @source, package.srcdir ]
            Subprocess.run(package, :import, *options)
        end
    end

    # Creates a subversion importer which import the source for the Subversion
    # URL +source+. The allowed values in +options+ are described in SVN.new.
    def self.svn(source, options = {})
        SVN.new(source, options)
    end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
autobuild-1.5.23 lib/autobuild/import/svn.rb
autobuild-1.5.22 lib/autobuild/import/svn.rb
autobuild-1.5.21 lib/autobuild/import/svn.rb
autobuild-1.5.21.rc1 lib/autobuild/import/svn.rb
autobuild-1.5.20 lib/autobuild/import/svn.rb
autobuild-1.5.19 lib/autobuild/import/svn.rb
autobuild-1.5.18 lib/autobuild/import/svn.rb
autobuild-1.5.17 lib/autobuild/import/svn.rb
autobuild-1.5.16 lib/autobuild/import/svn.rb
autobuild-1.5.15 lib/autobuild/import/svn.rb
autobuild-1.5.14 lib/autobuild/import/svn.rb
autobuild-1.5.13 lib/autobuild/import/svn.rb
autobuild-1.5.12 lib/autobuild/import/svn.rb
autobuild-1.5.11 lib/autobuild/import/svn.rb
autobuild-1.5.10 lib/autobuild/import/svn.rb
autobuild-1.5.9 lib/autobuild/import/svn.rb
autobuild-1.5.8 lib/autobuild/import/svn.rb
autobuild-1.5.7 lib/autobuild/import/svn.rb
autobuild-1.5.6 lib/autobuild/import/svn.rb
autobuild-1.5.5 lib/autobuild/import/svn.rb