|
47 | 47 | import com.diffplug.common.collect.Table; |
48 | 48 | import com.diffplug.spotless.FileSignature; |
49 | 49 |
|
| 50 | +import static com.diffplug.spotless.FileSignature.pathNativeToUnix; |
| 51 | +import static org.eclipse.jgit.treewalk.TreeWalk.forPath; |
| 52 | + |
50 | 53 | /** |
51 | 54 | * How to use: |
52 | 55 | * - For best performance, you should have one instance of GitRatchet, shared by all projects. |
|
57 | 60 | public abstract class GitRatchet<Project> implements AutoCloseable { |
58 | 61 |
|
59 | 62 | public boolean isClean(Project project, ObjectId treeSha, File file) throws IOException { |
60 | | - Repository repo = repositoryFor(project); |
61 | | - String relativePath = FileSignature.pathNativeToUnix(repo.getWorkTree().toPath().relativize(file.toPath()).toString()); |
62 | | - return isClean(project, treeSha, relativePath); |
| 63 | + return isClean(project, treeSha, pathNativeToUnix(repositoryFor(project).getWorkTree().toPath().relativize(file.toPath()).toString())); |
63 | 64 | } |
64 | 65 |
|
65 | 66 | private final Map<Repository, DirCache> dirCaches = new HashMap<>(); |
@@ -210,8 +211,7 @@ public synchronized ObjectId subtreeShaOf(Project project, ObjectId rootTreeSha) |
210 | 211 | if (repo.getWorkTree().equals(directory)) { |
211 | 212 | subtreeSha = rootTreeSha; |
212 | 213 | } else { |
213 | | - String subpath = FileSignature.pathNativeToUnix(repo.getWorkTree().toPath().relativize(directory.toPath()).toString()); |
214 | | - TreeWalk treeWalk = TreeWalk.forPath(repo, subpath, rootTreeSha); |
| 214 | + TreeWalk treeWalk = forPath(repo, pathNativeToUnix(repo.getWorkTree().toPath().relativize(directory.toPath()).toString()), rootTreeSha); |
215 | 215 | subtreeSha = treeWalk == null ? ObjectId.zeroId() : treeWalk.getObjectId(0); |
216 | 216 | } |
217 | 217 | subtreeShaCache.put(project, subtreeSha.copy()); |
|
0 commit comments