MWE for Eclipse jgit
- Open the folder in IntelliJ
- Navigate to
JGitTest(possibly using Ctrl+N and then typingJGitTestand then pressing Enter) - Run the test
testCloneRepositoryby clicking on the green arrow next to the class name
- Open the folder in IntelliJ
- Navigate to
JGitTest(possibly using Ctrl+N and then typingJGitTestand then pressing Enter) - Set a breakpoint by clicking on the left margin next to the line number of
assertTrue(Files.exists(repoDir)); - Run the test
testCloneRepositoryin debug mode by clicking on the green bug next to the method name - Wait
- You should see in the console an output similar to
INFO: Cloned repository to C:\Users\koppor\AppData\Local\Temp\junit-6524094164121122642 - Open "git bash"
- Execute
cd "C:\Users\koppor\AppData\Local\Temp\junit-6524094164121122642" - You are in the repository folder now and you can use your git tools to inspect the repository
The test testClonePrivateRepository requires credentials.
It requires two environment variables be set:
GH_USERNAME: Your GitHub username. Example:kopporGH_PAT: Your GitHub Personal Access Token. The simplest way to create one is using a classic PAT with thereposcope. Example:ghp_fY4dO1EoFZeKRALy9lmoZ6HlHTdfq4OATQhU
You can set them in IntelliJ by clicking at the top right the green arrow next to the class name, then "Edit Configurations...", then "Configuration" tab, then "Environment variables" and then adding the two variables. You can also it per test run settings:
JGitTest > testClonePrivateRepository() FAILED
org.opentest4j.AssertionFailedError at JGitTest.java:33
This means, you do not have set the environment variables properly.
