diff --git a/Sources/XCResource/Shared/Shell.swift b/Sources/XCResource/Shared/Shell.swift index 8c5156b..9ef129a 100644 --- a/Sources/XCResource/Shared/Shell.swift +++ b/Sources/XCResource/Shared/Shell.swift @@ -12,7 +12,7 @@ public struct GitReference { enum ShellCommand { case open(path: String) - case gitDownload(url: String, reference: GitReference, destination: String) + case gitDownload(url: URL, reference: GitReference, destination: URL) } class Shell { @@ -56,9 +56,20 @@ private extension ShellCommand { func shell() -> String { switch self { case let .gitDownload(url, reference, destination): - return "git clone -b '\(reference.name)' --single-branch --depth 1 \(url) \(destination)" + return "git clone -b '\(reference.name)' --single-branch --depth 1 \(url.toString()) \(destination.toString())" case let .open(path): return "open \(path)" } } } + +private extension URL { + + func toString() -> String { + if isFileURL { + return path // we remove the file: prefix + } else { + return absoluteString + } + } +} diff --git a/Sources/XCResource/XCSnippet/XCSnippetDownloadingStrategy.swift b/Sources/XCResource/XCSnippet/XCSnippetDownloadingStrategy.swift index e611ff7..4326b6f 100644 --- a/Sources/XCResource/XCSnippet/XCSnippetDownloadingStrategy.swift +++ b/Sources/XCResource/XCSnippet/XCSnippetDownloadingStrategy.swift @@ -41,7 +41,7 @@ struct GitSourceSnippetDownloadingStrategy: XCSnippetDownloadingStrategy { try? fileManager.removeItem(at: tmp) } try Shell().execute( - .gitDownload(url: url.absoluteString, reference: reference, destination: tmp.path) + .gitDownload(url: url, reference: reference, destination: tmp) ) let snippetsDirectoryURL = tmp.appendingPathComponent(folderPath) let snippetURLs = try fileManager.contentsOfDirectory(at: snippetsDirectoryURL) diff --git a/Sources/XCResource/XCTemplate/XCTemplateFolderDownloadingStrategyFactory.swift b/Sources/XCResource/XCTemplate/XCTemplateFolderDownloadingStrategyFactory.swift index 2a81347..9c17eec 100644 --- a/Sources/XCResource/XCTemplate/XCTemplateFolderDownloadingStrategyFactory.swift +++ b/Sources/XCResource/XCTemplate/XCTemplateFolderDownloadingStrategyFactory.swift @@ -42,9 +42,9 @@ struct GitSourceDownloadingStrategy: XCTemplateFolderDownloadingStrategy { } try Shell().execute( .gitDownload( - url: url.path, + url: url, reference: reference, - destination: tmp.path + destination: tmp ) ) let folder = try templateManager.templateFolder(at: tmp.appendingPathComponent(folderPath))