Support .bazelignore file for external repo

Fixes https://github.com/bazelbuild/bazel/issues/10234
Fixes https://github.com/bazelbuild/bazel/issues/9080

Closes #10261.

RELNOTES[NEW]:
Similar to the [.bazelignore](https://docs.bazel.build/versions/master/guide.html#.bazelignore) in the main repository, a `.bazelignore` file in external repository will cause the specified directories to be ignored by Bazel. Bazel won't try to identify any packages under the directories, but the files can still be referenced in other BUILD files.

PiperOrigin-RevId: 285412849
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/GlobFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/GlobFunction.java
index 8f125a1..24a1813 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/GlobFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/GlobFunction.java
@@ -20,6 +20,7 @@
 import com.google.devtools.build.lib.actions.FileValue;
 import com.google.devtools.build.lib.actions.InconsistentFilesystemException;
 import com.google.devtools.build.lib.cmdline.PackageIdentifier;
+import com.google.devtools.build.lib.cmdline.RepositoryName;
 import com.google.devtools.build.lib.collect.nestedset.NestedSet;
 import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
 import com.google.devtools.build.lib.vfs.Dirent;
@@ -56,8 +57,10 @@
       throws GlobFunctionException, InterruptedException {
     GlobDescriptor glob = (GlobDescriptor) skyKey.argument();
 
+    RepositoryName repositoryName = glob.getPackageId().getRepository();
     BlacklistedPackagePrefixesValue blacklistedPackagePrefixes =
-        (BlacklistedPackagePrefixesValue) env.getValue(BlacklistedPackagePrefixesValue.key());
+        (BlacklistedPackagePrefixesValue)
+            env.getValue(BlacklistedPackagePrefixesValue.key(repositoryName));
     if (env.valuesMissing()) {
       return null;
     }
@@ -79,7 +82,7 @@
               env.getValue(
                   PackageLookupValue.key(
                       PackageIdentifier.create(
-                          glob.getPackageId().getRepository(),
+                          repositoryName,
                           glob.getPackageId().getPackageFragment().getRelative(globSubdir))));
       if (globSubdirPkgLookupValue == null) {
         return null;