File tree Expand file tree Collapse file tree 1 file changed +15
-16
lines changed
Expand file tree Collapse file tree 1 file changed +15
-16
lines changed Original file line number Diff line number Diff line change @@ -214,22 +214,21 @@ public final class Runfiles {
214214 }
215215}
216216
217- // https://github.com/bazel-contrib/rules_go/blob/6505cf2e4f0a768497b123a74363f47b711e1d02/go/runfiles/global.go#L53-L54
218- private let legacyExternalGeneratedFile = /bazel-out\/ [ ^\/]+\/bin\/external\/ ( [ ^\/]+)/
219- private let legacyExternalFile = /external\/ ( [ ^\/]+)/
220-
221- // Extracts the canonical name of the repository containing the file
222- // located at `path`.
223- private func repository( from path: String) - > String {
224- if let match = path. prefixMatch ( of: legacyExternalGeneratedFile) {
225- return String ( match. 1 )
226- }
227- if let match = path. prefixMatch ( of: legacyExternalFile) {
228- return String ( match. 1 )
229- }
230- // If a file is not in an external repository, return an empty string
231- return " "
232- }
217+ // https://github.com/bazel-contrib/rules_go/blob/6505cf2e4f0a768497b123a74363f47b711e1d02/go/runfiles/global.go#L53-L54
218+ #if swift(>=5.10)
219+ nonisolated ( unsafe) private let legacyExternalGeneratedFile = /bazel-out\/ [ ^\/]+\/bin\/external\/ ( [ ^\/]+)/
220+ nonisolated ( unsafe) private let legacyExternalFile = /external\/ ( [ ^\/]+)/
221+ #else
222+ private let legacyExternalGeneratedFile = /bazel-out\/ [ ^\/]+\/bin\/external\/ ( [ ^\/]+)/
223+ private let legacyExternalFile = /external\/ ( [ ^\/]+)/
224+ #endif
225+
226+ // Extracts the canonical name of the repository containing the file
227+ // located at `path`.
228+ private func repository( from path: String) - > String {
229+ let match = path. prefixMatch ( of: legacyExternalGeneratedFile) ?? path. prefixMatch ( of: legacyExternalFile)
230+ return match. map { String ( $0. 1 ) } ?? " "
231+ }
233232
234233// MARK: Runfiles Paths Computation
235234
You can’t perform that action at this time.
0 commit comments