37 lines
897 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2020-08-23 06:00:17 +02:00
require "system_command"
module Utils
2020-08-23 06:00:17 +02:00
# Helper functions for querying SVN information.
#
# @api private
module Svn
module_function
2017-08-24 01:30:29 +05:30
2020-08-23 06:00:17 +02:00
def available?
version.present?
end
2018-09-17 02:45:00 +02:00
2020-08-23 06:00:17 +02:00
def version
return @version if defined?(@version)
2020-08-23 06:00:17 +02:00
stdout, _, status = system_command(HOMEBREW_SHIMS_PATH/"scm/svn", args: ["--version"], print_stderr: false)
@version = status.success? ? stdout.chomp[/svn, version (\d+(?:\.\d+)*)/, 1] : nil
end
2020-08-23 06:00:17 +02:00
def remote_exists?(url)
return true unless available?
2020-08-23 06:00:17 +02:00
# OK to unconditionally trust here because we're just checking if
# a URL exists.
quiet_system "svn", "ls", url, "--depth", "empty",
"--non-interactive", "--trust-server-cert"
end
2018-09-17 02:45:00 +02:00
2020-08-23 06:00:17 +02:00
def clear_version_cache
remove_instance_variable(:@version) if defined?(@version)
end
end
end