Workaround vcs/restore issues on Windows (#4042)

Potential workaround to line endings problems after `vcs/restore` operation is executed.

# Important Notes
Not really able to reproduce the problem myself so this PR has a lot of _leap of faith_ in it.
This commit is contained in:
Hubert Plociniczak 2023-01-12 13:28:09 +01:00 committed by GitHub
parent fc62b3b60c
commit a3de151ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,11 +38,17 @@ private class Git(ensoDataDirectory: Option[Path]) extends VcsApi[BlockingIO] {
private def repository(root: Path): Repository = {
val builder = new FileRepositoryBuilder()
builder
val repo = builder
.setWorkTree(root.toFile)
.setGitDir(root.resolve(gitDir).toFile)
.setMustExist(true)
.build()
disableAutoCRLF(repo)
repo
}
private def disableAutoCRLF(repo: Repository): Unit = {
repo.getConfig.setString("core", null, "autocrlf", "false")
}
override def init(root: Path): BlockingIO[VcsFailure, Unit] = {
@ -71,6 +77,7 @@ private class Git(ensoDataDirectory: Option[Path]) extends VcsApi[BlockingIO] {
.setDirectory(root.toFile)
.setBare(false)
.call()
disableAutoCRLF(jgit.getRepository)
ensoDataDirectory.foreach { _ =>
// When `gitDir` is set, JGit **always** creates a .git file (not a directory!) that points at the real