Sha256: 2ec993a0cab0fc05734d19a747ce03fcaa1dff46b6814fcd86895215702fc745

Contents?: true

Size: 942 Bytes

Versions: 7

Compression:

Stored size: 942 Bytes

Contents

require 'r10k/util/subprocess'

class R10K::SVN::Remote

  def initialize(baseurl)
    @baseurl = baseurl
  end

  # @todo validate that the path to trunk exists in the remote
  def trunk
    "#{@baseurl}/trunk"
  end

  # @todo gracefully handle cases where no branches exist
  def branches
    text = svn ['ls', "#{@baseurl}/branches"]
    text.lines.map do |line|
      line.chomp!
      line.gsub!(%r[/$], '')
      line
    end
  end

  private

  include R10K::Logging

  # Wrap SVN commands
  #
  # @param argv [Array<String>]
  # @param opts [Hash]
  #
  # @option opts [Pathname] :cwd The directory to run the command in
  #
  # @return [String] The stdout from the given command
  def svn(argv, opts = {})
    argv.unshift('svn')

    subproc = R10K::Util::Subprocess.new(argv)
    subproc.raise_on_fail = true
    subproc.logger = self.logger

    subproc.cwd = opts[:cwd]
    result = subproc.execute

    result.stdout
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
r10k-1.3.5 lib/r10k/svn/remote.rb
r10k-1.3.4 lib/r10k/svn/remote.rb
r10k-1.3.3 lib/r10k/svn/remote.rb
r10k-1.3.2 lib/r10k/svn/remote.rb
r10k-1.3.1 lib/r10k/svn/remote.rb
r10k-1.3.0 lib/r10k/svn/remote.rb
r10k-1.3.0rc1 lib/r10k/svn/remote.rb