1

I am programmatically trying to clone a repo using the JGit API. I am using the following piece of code, but when I execute it, I am getting an error.

I have tried all possible solutions which I could find but still I am unable to resolve the problem. Can anyone provide inputs?

File localPath = File.createTempFile("TestGitRepository", "");
Git result = Git.cloneRepository()
                .setURI("https://gitlab.wuintranet.net/fe/wu-content.git")
                .setDirectory(localPath)
                .call(); 

The repo at "https://gitlab.wuintranet.net/fe/wu-content.git" should get cloned but it is throwing this error:

java.nio.file.AccessDeniedException: C:\Program Files\Git\mingw64\etc.probe-e65aa729-82b1-4ff9-8d9b-3a4a7ea3de4a
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Johna
  • 85
  • 1
  • 8
  • 1
    You're creating a file, and then using it as a directory. Not gonna work. – Maurice Perry Jun 20 '19 at 06:45
  • Possible duplicate of [How to create a temporary directory/folder in Java?](https://stackoverflow.com/questions/617414/how-to-create-a-temporary-directory-folder-in-java) – krokodilko Jun 20 '19 at 07:15
  • 1
    I don't think, that this is a duplicate. I have the same problem but without the createTempFile() – Nexonus Jul 02 '19 at 09:55

2 Answers2

1

It looks like a bug they found in last version."5.3.1.201904271842-r" is working for me. you can go back. here is the details

https://github.com/diffplug/spotless/issues/410

ozkanpakdil
  • 3,199
  • 31
  • 48
0

I got the same problem under windows during gradle tests. Running the console to from which i start the test in admin mode worked for me. On other operating systems running it with sudo might work.

NotMyFaultSir
  • 173
  • 11