class R10K::SVN::Remote

Inspect and interact with SVN remote repositories

@api private @since 1.3.0

Public Class Methods

new(baseurl, opts = {}) click to toggle source
# File lib/r10k/svn/remote.rb, line 12
def initialize(baseurl, opts = {})
  @baseurl = baseurl
  setopts(opts, {:username => :self, :password => :self})
end

Public Instance Methods

branches() click to toggle source

@todo gracefully handle cases where no branches exist

# File lib/r10k/svn/remote.rb, line 23
def branches
  argv = ['ls', "#{@baseurl}/branches"]
  argv.concat(auth)
  text = svn(argv)
  text.lines.map do |line|
    line.chomp!
    line.gsub!(%r[/$], '')
    line
  end
end
trunk() click to toggle source

@todo validate that the path to trunk exists in the remote

# File lib/r10k/svn/remote.rb, line 18
def trunk
  "#{@baseurl}/trunk"
end

Private Instance Methods

auth() click to toggle source

Format authentication information for SVN command args, if applicable

# File lib/r10k/svn/remote.rb, line 37
def auth
  auth = []
  if @username
    auth << "--username" << @username
    auth << "--password" << @password
  end
  auth
end
svn(argv, opts = {}) click to toggle source

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

# File lib/r10k/svn/remote.rb, line 56
def svn(argv, opts = {})
  argv.unshift('svn', '--non-interactive')

  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