svn: add flags if needed for :trust_cert or remote_exists?

This commit is contained in:
EricFromCanada 2021-10-21 20:51:00 -04:00
parent 0e0593418d
commit 093e6e11da
No known key found for this signature in database
GPG Key ID: 179D9CDDDB814168
2 changed files with 16 additions and 6 deletions

View File

@ -763,10 +763,7 @@ class SubversionDownloadStrategy < VCSDownloadStrategy
args << "--ignore-externals" if ignore_externals
if meta[:trust_cert] == true
args << "--trust-server-cert"
args << "--non-interactive"
end
args.concat Utils::Svn.invalid_cert_flags if meta[:trust_cert] == true
if target.directory?
command! "svn", args: ["update", *args], chdir: target.to_s, timeout: timeout&.remaining

View File

@ -30,9 +30,22 @@ module Utils
def remote_exists?(url)
return true unless available?
args = ["ls", url, "--depth", "empty"]
_, stderr, status = system_command("svn", args: args, print_stderr: false)
return status.success? unless stderr.include?("certificate verification failed")
# OK to unconditionally trust here because we're just checking if a URL exists.
system_command("svn", args: ["ls", url, "--depth", "empty",
"--non-interactive", "--trust-server-cert"], print_stderr: false).success?
system_command("svn", args: args.concat(invalid_cert_flags), print_stderr: false).success?
end
sig { returns(Array) }
def invalid_cert_flags
opoo "Ignoring Subversion certificate errors!"
args = ["--non-interactive", "--trust-server-cert"]
if Version.create(version || "-1") >= Version.create("1.9")
args << "--trust-server-cert-failures=expired,not-yet-valid"
end
args
end
def clear_version_cache