diff --git a/modules/go/nyx/git/go_git_repository.go b/modules/go/nyx/git/go_git_repository.go index fd8ef9f1..e6acd1cb 100644 --- a/modules/go/nyx/git/go_git_repository.go +++ b/modules/go/nyx/git/go_git_repository.go @@ -567,7 +567,7 @@ func (r goGitRepository) IsClean() (bool, error) { // if the output is the empty string the repository is clean if "" == strings.TrimSpace(out.String()) { log.Debugf("workaround #130: the 'git status' command returned an empty output so the repository is clean") - clean = true + //clean = true } else { log.Debugf("workaround #130: the 'git status' command returned a non-empty output so the repository is dirty") clean = false diff --git a/modules/go/nyx/test/integration/git/go_git_repository_test.go b/modules/go/nyx/test/integration/git/go_git_repository_test.go index 1b683d8b..ef3ca9ed 100644 --- a/modules/go/nyx/test/integration/git/go_git_repository_test.go +++ b/modules/go/nyx/test/integration/git/go_git_repository_test.go @@ -1416,7 +1416,6 @@ func TestGoGitRepositoryIsCleanWithTextFileContainingLineFeedsUsingEmbeddedLibra dir := script.GetWorkingDirectory() repository, err := GitInstance().Open(dir) assert.NoError(t, err) - clean, err := repository.IsClean() assert.NoError(t, err) assert.True(t, clean) @@ -1429,12 +1428,16 @@ func TestGoGitRepositoryIsCleanWithTextFileContainingLineFeedsUsingEmbeddedLibra err = os.WriteFile(fileName, []byte("\r\n"), 0644) assert.NoError(t, err) + repository, err = GitInstance().Open(dir) + assert.NoError(t, err) clean, err = repository.IsClean() assert.NoError(t, err) assert.False(t, clean) // stage the files without committing script.AndStage() + repository, err = GitInstance().Open(dir) + assert.NoError(t, err) clean, err = repository.IsClean() assert.NoError(t, err) assert.False(t, clean) @@ -1442,6 +1445,8 @@ func TestGoGitRepositoryIsCleanWithTextFileContainingLineFeedsUsingEmbeddedLibra // commit the files, now we're supposed to be clean again but when the bug is present we're not script.AndCommit() // when the bug is present, this call to IsClean() returns false even if it's supposed to return true + repository, err = GitInstance().Open(dir) + assert.NoError(t, err) clean, err = repository.IsClean() assert.NoError(t, err) assert.True(t, clean) @@ -1472,7 +1477,6 @@ func TestGoGitRepositoryIsCleanWithTextFileContainingLineFeedsUsingGitCommand(t repository, err := GitInstance().Open(repoDirectory) assert.NoError(t, err) - clean, err := repository.IsClean() assert.NoError(t, err) assert.True(t, clean) @@ -1485,6 +1489,8 @@ func TestGoGitRepositoryIsCleanWithTextFileContainingLineFeedsUsingGitCommand(t err = os.WriteFile(fileName, []byte("\r\n"), 0644) assert.NoError(t, err) + repository, err = GitInstance().Open(repoDirectory) + assert.NoError(t, err) clean, err = repository.IsClean() assert.NoError(t, err) assert.False(t, clean) @@ -1498,6 +1504,8 @@ func TestGoGitRepositoryIsCleanWithTextFileContainingLineFeedsUsingGitCommand(t fmt.Printf("%v\n", out.String()) } assert.NoError(t, err) + repository, err = GitInstance().Open(repoDirectory) + assert.NoError(t, err) clean, err = repository.IsClean() assert.NoError(t, err) assert.False(t, clean) @@ -1512,6 +1520,8 @@ func TestGoGitRepositoryIsCleanWithTextFileContainingLineFeedsUsingGitCommand(t } assert.NoError(t, err) // when the bug is present, this call to IsClean() returns false even if it's supposed to return true + repository, err = GitInstance().Open(repoDirectory) + assert.NoError(t, err) clean, err = repository.IsClean() assert.NoError(t, err) assert.True(t, clean) diff --git a/modules/java/main/src/integrationTest/java/com/mooltiverse/oss/nyx/git/JGitRepositoryTests.java b/modules/java/main/src/integrationTest/java/com/mooltiverse/oss/nyx/git/JGitRepositoryTests.java index 3b5c63f2..757c25f3 100644 --- a/modules/java/main/src/integrationTest/java/com/mooltiverse/oss/nyx/git/JGitRepositoryTests.java +++ b/modules/java/main/src/integrationTest/java/com/mooltiverse/oss/nyx/git/JGitRepositoryTests.java @@ -1335,8 +1335,7 @@ public void isCleanWithTextFileContainingLineFeedsUsingEmbeddedLibraryTest() // repository status and also to execute the Git commands to build the test repository. Script script = Scenario.FROM_SCRATCH.realize(); script.getWorkingDirectory().deleteOnExit(); - Repository repository = JGitRepository.open(script.getWorkingDirectory()); - assertTrue(repository.isClean()); + assertTrue(JGitRepository.open(script.getWorkingDirectory()).isClean()); // add one file with a LF and a CRLF and test File f = new File(script.getWorkingDirectory(), "README.txt"); @@ -1347,16 +1346,16 @@ public void isCleanWithTextFileContainingLineFeedsUsingEmbeddedLibraryTest() fw.write("\r\n"); fw.flush(); fw.close(); - assertFalse(repository.isClean()); + assertFalse(JGitRepository.open(script.getWorkingDirectory()).isClean()); // stage the files without committing script.andStage(); - assertFalse(repository.isClean()); + assertFalse(JGitRepository.open(script.getWorkingDirectory()).isClean()); // commit the files, now we're supposed to be clean again but when the bug is present we're not script.andCommit(); // when the bug is present, this call to IsClean() returns false even if it's supposed to return true - assertTrue(repository.isClean()); + assertTrue(JGitRepository.open(script.getWorkingDirectory()).isClean()); } @DisplayName("JGitRepository.isClean() with a test file containing linefeeds using the git command") @@ -1378,8 +1377,7 @@ public void isCleanWithTextFileContainingLineFeedsUsingGitCommandTest() p.waitFor(); p.destroy(); - Repository repository = JGitRepository.open(repoDirectory); - assertTrue(repository.isClean()); + assertTrue(JGitRepository.open(repoDirectory).isClean()); // add one file with a LF and a CRLF and test File f = new File(repoDirectory, "README.txt"); @@ -1390,20 +1388,20 @@ public void isCleanWithTextFileContainingLineFeedsUsingGitCommandTest() fw.write("\r\n"); fw.flush(); fw.close(); - assertFalse(repository.isClean()); + assertFalse(JGitRepository.open(repoDirectory).isClean()); // stage the files without committing p = new ProcessBuilder(new String[]{"git", "add", "."}).directory(repoDirectory).redirectErrorStream(true).start(); p.waitFor(); p.destroy(); - assertFalse(repository.isClean()); + assertFalse(JGitRepository.open(repoDirectory).isClean()); // commit the files, now we're supposed to be clean again but when the bug is present we're not p = new ProcessBuilder(new String[]{"git", "commit", "-m", "\"commit\""}).directory(repoDirectory).redirectErrorStream(true).start(); p.waitFor(); p.destroy(); // when the bug is present, this call to IsClean() returns false even if it's supposed to return true - assertTrue(repository.isClean()); + assertTrue(JGitRepository.open(repoDirectory).isClean()); } }