Skip to content

Commit

Permalink
fix: Query Sync can now work with '.' in the directories section (#6834)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpasternak authored Oct 3, 2024
1 parent 3f676d4 commit 7b52b42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.google.idea.blaze.qsync.query.Query.Rule;
import com.google.idea.blaze.qsync.query.QuerySummary;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -97,8 +98,12 @@ public BuildGraphData parse() {
for (Map.Entry<Label, Query.SourceFile> sourceFileEntry :
query.getSourceFilesMap().entrySet()) {
Location l = new Location(sourceFileEntry.getValue().getLocation());
if (l.file.endsWith(Path.of("BUILD"))) {
packages.add(l.file.getParent());
if (l.file.endsWith(Path.of("BUILD")) || l.file.endsWith(Path.of("BUILD.bazel"))){
if(l.file.getParent() == null){
packages.add(Paths.get(""));
} else{
packages.add(l.file.getParent());
}
}
graphBuilder.locationsBuilder().put(sourceFileEntry.getKey(), l);
graphBuilder.fileToTargetBuilder().put(l.file, sourceFileEntry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ ImmutableMap<Path, ImmutableMap<Path, String>> splitByRoot(Map<Path, String> pre
ImmutableMap.Builder<Path, String> inRoot = ImmutableMap.builder();
for (Entry<Path, String> pkg : prefixes.entrySet()) {
Path rel = pkg.getKey();
if (rel.startsWith(root)) {
if (rel.startsWith(root) || root.toString().equals("")) {
Path relToRoot = root.relativize(rel);
inRoot.put(relToRoot, pkg.getValue());
}
Expand Down

0 comments on commit 7b52b42

Please sign in to comment.