From c6cfd51fb4f048576c275077d96cdb5d1a361545 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Tue, 29 Sep 2020 12:44:33 +0100 Subject: [PATCH] Use the NoGitignoreIterator recursively --- .../wlgitbridge/bridge/repo/NoGitignoreIterator.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/NoGitignoreIterator.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/NoGitignoreIterator.java index 065aa6d024..64103c075e 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/NoGitignoreIterator.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/repo/NoGitignoreIterator.java @@ -1,6 +1,7 @@ package uk.ac.ic.wlgitbridge.bridge.repo; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.treewalk.AbstractTreeIterator; import org.eclipse.jgit.treewalk.FileTreeIterator; import org.eclipse.jgit.treewalk.WorkingTreeIterator; import org.eclipse.jgit.treewalk.WorkingTreeOptions; @@ -64,6 +65,8 @@ public class NoGitignoreIterator extends FileTreeIterator { super(p, root, fs, fileModeStrategy); } + // Note: the `list` is a list of top-level entities in this directory, + // not a full list of files in the tree. @Override protected void init(Entry[] list) { super.init(list); @@ -74,4 +77,11 @@ public class NoGitignoreIterator extends FileTreeIterator { } } + // When entering a sub-directory, create a new instance of this class, + // so we can also ignore gitignore specifications in sub-directories + @Override + protected AbstractTreeIterator enterSubtree() { + String fullPath = getDirectory().getAbsolutePath() + "/" + current().getName(); + return new NoGitignoreIterator(this, new File(fullPath), fs, fileModeStrategy); + } }