Skip to content

[5.4] Enable symlink support for Git, and suppress symlink error #3559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Sources/Build/BuildOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,18 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
component: buildParameters.configuration.dirname
)
if localFileSystem.exists(oldBuildPath) {
try localFileSystem.removeFileTree(oldBuildPath)
do { try localFileSystem.removeFileTree(oldBuildPath) }
catch {
diagnostics.emit(warning: "unable to delete \(oldBuildPath), skip creating symbolic link: \(error)")
return
}
}

do {
try localFileSystem.createSymbolicLink(oldBuildPath, pointingAt: buildParameters.buildPath, relative: true)
} catch {
diagnostics.emit(warning: "unable to create symbolic link at \(oldBuildPath): \(error)")
}
try localFileSystem.createSymbolicLink(oldBuildPath, pointingAt: buildParameters.buildPath, relative: true)
}

/// Compute the llbuild target name using the given subset.
Expand Down
21 changes: 0 additions & 21 deletions Sources/SourceControl/GitRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,9 @@ public struct GitRepositoryProvider: RepositoryProvider {
// FIXME: Ideally we should pass `--progress` here and report status regularly. We currently don't have callbacks for that.
//
// NOTE: Explicitly set `core.symlinks=true` on `git clone` to ensure that symbolic links are correctly resolved.
// FIXME: Remove the judgement before a cross-platform release
#if os(Windows)
try self.callGit("clone", "-c", "core.symlinks=true", "--mirror", repository.url, path.pathString,
repository: repository,
failureMessage: "Failed to clone repository \(repository.url)")
#else
try self.callGit("clone", "--mirror", repository.url, path.pathString,
repository: repository,
failureMessage: "Failed to clone repository \(repository.url)")
#endif
}

public func copy(from sourcePath: AbsolutePath, to destinationPath: AbsolutePath) throws {
Expand All @@ -116,16 +109,9 @@ public struct GitRepositoryProvider: RepositoryProvider {
// present in the bare repository.
//
// NOTE: Explicitly set `core.symlinks=true` on `git clone` to ensure that symbolic links are correctly resolved.
// FIXME: Remove the judgement before a cross-platform release
#if os(Windows)
try self.callGit("clone", "-c", "core.symlinks=true", "--no-checkout", sourcePath.pathString, destinationPath.pathString,
repository: repository,
failureMessage: "Failed to clone repository \(repository.url)")
#else
try self.callGit("clone", "--no-checkout", sourcePath.pathString, destinationPath.pathString,
repository: repository,
failureMessage: "Failed to clone repository \(repository.url)")
#endif
// The default name of the remote.
let origin = "origin"
// In destination repo remove the remote which will be pointing to the source repo.
Expand All @@ -145,16 +131,9 @@ public struct GitRepositoryProvider: RepositoryProvider {
// object storage.
//
// NOTE: Explicitly set `core.symlinks=true` on `git clone` to ensure that symbolic links are correctly resolved.
// FIXME: Remove the judgement before a cross-platform release
#if os(Windows)
try self.callGit("clone", "-c", "core.symlinks=true", "--shared", "--no-checkout", sourcePath.pathString, destinationPath.pathString,
repository: repository,
failureMessage: "Failed to clone repository \(repository.url)")
#else
try self.callGit("clone", "--shared", "--no-checkout", sourcePath.pathString, destinationPath.pathString,
repository: repository,
failureMessage: "Failed to clone repository \(repository.url)")
#endif
}
}

Expand Down