GumTreeDiff / gumtree

An awesome code differencing tool
https://github.com/GumTreeDiff/gumtree/wiki
GNU Lesser General Public License v3.0
917 stars 173 forks source link

Respect .gitignore #329

Closed koppor closed 8 months ago

koppor commented 8 months ago

I tried to use the tool as git diff. I have following output:

image

I used the git worktree feature to provide paths on disk to inspect.

out and build are ignored paths and should not play a role in a diff.

I would have assumed that Gumtree respects the filtering rules of .gitignore.

koppor commented 8 months ago

It would also be nice if sub modules were not handled. (path src/main/resources/csl-styles in my case)

jrfaller commented 8 months ago

Hi! Did you try using git difftool because I think it handles that -> https://github.com/GumTreeDiff/gumtree/wiki/VCS-Integration ?

koppor commented 8 months ago

Oh, nice hint. OK for me.

My setting is

[diff]
tool = gumtree
[difftool "gumtree"]
cmd = docker run --rm --no-symlinks -v $LOCAL:/diff/left -v $REMOTE:/diff/right -p 4567:4567 gumtreediff/gumtree webdiff left/ right/

Maybe, that can be added to the Wiki?

koppor commented 8 months ago

Does not work quite well.

git diff:

diff --git a/src/main/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheckResultTxtWriter.java b/src/main/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheckResultTxtWriter.java
index 2498d1d373..7eff41d74f 100644
--- a/src/main/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheckResultTxtWriter.java
+++ b/src/main/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheckResultTxtWriter.java
@@ -48,9 +48,7 @@ public class BibliographyConsistencyCheckResultTxtWriter extends BibliographyCon

         super.writeFindings();

-        writer.write("\n\n");
-        writer.write(Localization.lang("Legend"));
-        writer.write("\n\n");
+        writer.write("\n");
         writer.write("%s | %s\n".formatted(REQUIRED_FIELD_AT_ENTRY_TYPE_CELL_ENTRY, Localization.lang("required field is present")));
         writer.write("%s | %s\n".formatted(OPTIONAL_FIELD_AT_ENTRY_TYPE_CELL_ENTRY, Localization.lang("optional field is present")));
         writer.write("%s | %s\n".formatted(UNKNOWN_FIELD_AT_ENTRY_TYPE_CELL_ENTRY, Localization.lang("unknown field is present")));
diff --git a/src/test/java/org/jabref/logic/quality/consistency/BibliopraphyConsistencyCheckResultTxtWriterTest.java b/src/test/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheckResultTxtWriterTest.java
similarity index 91%
rename from src/test/java/org/jabref/logic/quality/consistency/BibliopraphyConsistencyCheckResultTxtWriterTest.java
rename to src/test/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheckResultTxtWriterTest.java
index 165668b294..df05bbfe34 100644
--- a/src/test/java/org/jabref/logic/quality/consistency/BibliopraphyConsistencyCheckResultTxtWriterTest.java
+++ b/src/test/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheckResultTxtWriterTest.java
@@ -23,7 +23,7 @@ import org.mockito.Answers;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.mock;

-class BibliopraphyConsistencyCheckResultTxtWriterTest {
+class BibliographyConsistencyCheckResultTxtWriterTest {
     private BibtexImporter importer = new BibtexImporter(mock(Imp

(and more)

GumTree:

image


Maybe, the exception should be catched earlier:

java.nio.file.NoSuchFileException: right/src/main/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheckResultTxtWriter.java
    at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
    at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
    at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:148)
    at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
    at java.base/java.nio.file.Files.readAttributes(Files.java:1851)
    at java.base/java.nio.file.Files.size(Files.java:2468)
    at com.github.gumtreediff.io.DirectoryComparator.hasChanged(DirectoryComparator.java:143)
    at com.github.gumtreediff.io.DirectoryComparator.compare(DirectoryComparator.java:100)
    at com.github.gumtreediff.client.diff.webdiff.WebDiff.run(WebDiff.java:81)
    at com.github.gumtreediff.client.Run.startClient(Run.java:94)
    at com.github.gumtreediff.client.Run.main(Run.java:128)
koppor commented 8 months ago

When using docker, one has also to bind the "real" linux path. Otherwise, a File is reported missing:

lrwxrwxrwx 1 1000 users  136 Feb  2 15:17 BibliographyConsistencyCheckResultTxtWriter.java -> /home/koppor/git-repositories/jabref/src/main/java/org/jabref/logic/quality/consistency/BibliographyConsistencyCheckResultTxtWriter.jav
koppor commented 8 months ago

i updated my setup above (https://github.com/GumTreeDiff/gumtree/issues/329#issuecomment-1924062924) to contain -no-symlinks. Works better.

The docker container, however, should keep running until Ctrl+C is pressed. Currently, it quits after a short time after printing Starting server: http://127.0.0.1:4567.. (User error)

jrfaller commented 8 months ago

Thanks for the beta-testing of docker with git! I updated the wiki with your configuration snippet.

koppor commented 8 months ago

@jrfaller The updated docs at https://github.com/GumTreeDiff/gumtree/tree/main/docker#usage-1 are really nice! Alias "gd" is really cool!

jrfaller commented 8 months ago

Awesome, I completely forgot that we had some documentation about that in the README of the docker folder ;-). I added a link to this doc in the wiki. Maybe I should update the doc to include the --rm option since it avoids overcrowding the machine with one time containers, no?