Skip to content

Commit

Permalink
Separate test case for JENKINS-38699 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
arpoch committed Mar 31, 2021
1 parent 91fb38a commit f10f877
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,16 +598,18 @@ public void testHasGitRepo() throws Exception {
assertTrue(emptyDir.exists());
GitClient emptyClient = Git.with(TaskListener.NULL, new EnvVars()).in(emptyDir).using(gitImplName).getClient();
assertFalse("Empty repo '" + emptyDir.getAbsolutePath() + "' initialized", emptyClient.hasGitRepo());
}

@Issue("JENKINS-38699")
@Test
public void test_worktree() throws Exception {
File badGitDir = tempFolder.newFolder("parentDir", "childDir", ".git");
assertEquals(".git", badGitDir.getName());
assertEquals("childDir", badGitDir.getParentFile().getName());
assertEquals("parentDir", badGitDir.getParentFile().getParentFile().getName());
gitClient.init_().workspace(badGitDir.getParentFile().getParentFile().getAbsolutePath()).execute();
File gitDir = gitClient.withRepository((repo, channel) -> repo.getDirectory());
assertTrue("Missing " + gitDir, gitDir.isDirectory());
GitClient childDirClient = Git.with(TaskListener.NULL, new EnvVars()).in((badGitDir.getParentFile())).using(gitImplName).getClient();
assertFalse("Empty repo '" + badGitDir.getParentFile() + "' initialized", childDirClient.hasGitRepo());
assertFalse("Empty .git directory in " + badGitDir.getParentFile().getName(), childDirClient.hasGitRepo());
}

@Test
Expand Down

0 comments on commit f10f877

Please sign in to comment.