@@ -0,0 +1,3226 @@
+/**%0A * Copyright (C) 2016 Matthieu Brouillard %5Bhttp://oss.brouillard.fr/jgitver%5D (matthieu@brouillard.fr)%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *         http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage fr.brouillard.oss.jgitver.issues;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0Aimport org.junit.jupiter.api.AfterAll;%0Aimport org.junit.jupiter.api.Assertions;%0Aimport org.junit.jupiter.api.BeforeAll;%0Aimport org.junit.jupiter.api.Test;%0A%0Aimport fr.brouillard.oss.jgitver.GitVersionCalculator;%0Aimport fr.brouillard.oss.jgitver.Misc;%0Aimport fr.brouillard.oss.jgitver.Scenarios;%0Aimport fr.brouillard.oss.jgitver.Version;%0A%0Apublic class Issue65NoFailTest %7B%0A    private static File wktreeDirectory;%0A    private static Scenarios.Scenario scenario;%0A%0A    public static Scenarios.Scenario init_scenario() %7B%0A        Scenarios.ScenarioBuilder builder = new Scenarios.ScenarioBuilder()%0A                .commit(%22content%22, %22A%22)%0A                .commit(%22content%22, %22B%22)%0A                .commit(%22content%22, %22C%22);%0A        builder.branchOnAppId(%22another%22, %22C%22);%0A        return builder.getScenario();%0A    %7D%0A%0A    @BeforeAll%0A    public static void init() %7B%0A        scenario = init_scenario();%0A        wktreeDirectory = init_worktree();%0A    %7D%0A%0A    @AfterAll%0A    public static void cleanup() %7B%0A        try %7B%0A            Misc.deleteDirectorySimple(scenario.getRepositoryLocation());%0A        %7D catch (Exception ignore) %7B%0A            System.err.println(%22cannot remove %22 + scenario.getRepositoryLocation());%0A        %7D%0A        try %7B%0A            Misc.deleteDirectorySimple(wktreeDirectory);%0A        %7D catch (Exception ignore) %7B%0A            System.err.println(%22cannot remove worktree at: %22 + wktreeDirectory);%0A        %7D%0A    %7D%0A%0A    private static File init_worktree() %7B%0A        File generatedProjectDirectory = scenario.getRepositoryLocation().getParentFile();%0A        File wkDir = new File(generatedProjectDirectory.getParent(), %22wktree%22);%0A        try %7B%0A            Process p =new ProcessBuilder(%22git%22, %22worktree%22, %22add%22, wkDir.getAbsolutePath().toString(), %22master%22)%0A                    .directory(generatedProjectDirectory)%0A                    .start();%0A%0A            try %7B%0A                p.waitFor();%0A            %7D catch (InterruptedException ignore) %7B%7D%0A%0A        %7D catch (IOException e) %7B%0A            Assertions.fail(e.getMessage());%0A        %7D%0A%0A        return wkDir;%0A    %7D%0A%0A    @Test%0A    public void can_execute_jgitver_on_worktree() %7B%0A        GitVersionCalculator worktreeCalculator = GitVersionCalculator.location(wktreeDirectory);%0A        String version = worktreeCalculator.getVersion();%0A        assertThat(version, is(Version.NO_WORKTREE_AND_INDEX.toString()));%0A    %7D%0A%7D%0A

add test case to ckeck git worktree does not fail with jgitver