Locate branches that contain a reference

@param string $reference reference

@throws \RuntimeException
@return string the command
779435
public function contains($reference)
    {
        $this->clearAll();
        $this->addCommandName(self::BRANCH_COMMAND);
        $this->addCommandArgument('--contains');
        $this->addCommandSubject($reference);

        return $this->getCommand();
    }
938511
protected function doGetDBRef(array $reference)
    {
        $mongoDB = $this->mongoDB;
        return $this->retry(function() use ($mongoDB, $reference) {
            return $mongoDB->getDBRef($reference);
        });
    }
1030655
public function findReferencedNodes(): TraversableNodes
    {
        $referencedNodes = [];
        foreach ($this->getNodeType()->getProperties() as $propertyName => $property) {
            $propertyType = $this->getNodeType()->getPropertyType($propertyName);
            if ($propertyType === 'reference' && $this->getProperty($propertyName) instanceof TraversableNodeInterface) {
                $referencedNodes[] = $this->getProperty($propertyName);
            } elseif ($propertyName === 'references' && !empty($this->getProperty($propertyName))) {
                foreach ($this->getProperty($propertyName) as $node) {
                    if ($node instanceof TraversableNodeInterface) {
                        $referencedNodes[] = $node;
                    }
                }
            }
        }

        return TraversableNodes::fromArray($referencedNodes);
    }
1080744
public function get_reference_details($reference, $filestatus = 0) {
        $details = $this->get_name().': '.$reference;
        if ($filestatus) {
            return get_string('lostsource', 'repository', $details);
        } else {
            return $details;
        }
    }
828971
protected function getReferenceValue(
        ReferenceAbstract $reference,
        /*# int */ $level = 0
    ) {
        $name = $reference->getName();

        // loop found
        if ($level > 2) {
            throw new NotFoundException(
                Message::get(Message::PARAMETER_LOOP_FOUND, $name),
                Message::PARAMETER_LOOP_FOUND
            );
        }

        // get service reference value
        if ($reference instanceof ServiceReference) {
            return $this->delegatedGet($name);

        // get parameter value, if value is another reference, go deeper
        } else {
            $val = $this->getParameter($name);
            if (is_string($val) && ($ref = $this->isReference($val))) {
                return $this->getReferenceValue($ref, ++$level);
            }
            return $val;
        }
    }
553356
public function resolve($reference)
    {
        $reference = substr($reference, 7);
        $method = $this->getMethod($reference);
        $callback = [
            $this->container->resolve($method->getOwner()),
            $method->getName()
        ];

        if ($method->hasArguments()) {
            return function () use($callback, $method)
            {
                return call_user_func_array($callback, $method->extractArguments($this->container, new ArrayResolver()));
            };
        }

        return is_array($callback) ? function () use ($callback) {
            return call_user_func_array($callback, func_get_args());
        } : $callback;
    }
996606
public function getSection($reference)
    {
        $reference = Section::trimReference($reference);
        $reference = strtolower(Section::normalizeReference($reference));

        foreach ($this->sections as $sectionKey => $section) {
            $potentialMatch = strtolower(Section::normalizeReference($sectionKey));
            if ($reference === $potentialMatch) {
                return $section;
            }
        }

        throw new UnexpectedValueException('Section with a reference of ' . $reference . ' cannot be found!');
    }
455949
public static function factoryReference($reference) {
    $className = $reference[2];
    if (!class_exists($className)) {
      throw new Exceptions\EntityClassNotFoundException(
          "factoryReference called for a class that can't be found, $className."
      );
    }
    $entity = call_user_func([$className, 'factory']);
    $entity->referenceSleep($reference);
    return $entity;
  }
277876
protected function doGetDBRef(array $reference)
    {
        $mongoCollection = $this->mongoCollection;
        return $this->retry(function() use ($mongoCollection, $reference) {
            return $mongoCollection->getDBRef($reference);
        });
    }
910694
public static function getReferenceId($reference, string $storeAs)
    {
        return $storeAs === self::REFERENCE_STORE_AS_ID ? $reference : $reference[self::getReferencePrefix($storeAs) . 'id'];
    }
1310435
protected function getByRef($key, &$value)
    {
        if (!$this->checkRefs ||!is_string($value)) {
            return;
        }

        $this->checkRefs = false;
        $references = [$key];
        $key = $value;
        while ($this->isRef($key)) {
            if (in_array($key, $references)) {
                $this->checkRefs = true;
                $this->key = null;
                $references[] = $key;
                throw new RuntimeException(sprintf(
                    "Cyclic reference detected: %s",
                    implode(" ~~> ", $references)
                ));
            }
            $references[] = $key;
            $previous = $key;
            $key = $this->get($key, null, false);
        };
        $this->checkRefs = true;
        if (isset($previous)) {
            if ($this->exists($previous)) {
                $value = $key;
            } else {
                $this->key = null;
                $references[sizeof($references) - 1] .= " (missing key)";
                throw new RuntimeException(sprintf(
                    "Invalid reference detected: %s",
                    implode(" ~~> ", $references)
                ));
            }
        }
    }
1098912
private function parseRefAsCommit($reference): ?string
    {
        if (preg_match(self::REGEX_COMMIT, $reference, $matches) !== 1) {
            return null;
        }

        return $matches[0];
    }
1202424
public function findReferences($rid, array $classes = array(), $append = true)
    {
        $commandClass = $this->getCommandClass('references.find');
        $this->command = new $commandClass($rid);
        $this->command->in($classes, $append);

        return $this->command;
    }
624776
public function remoteBranchExists($remote, $branch)
    {
        $result = $this->processHelper->runCommand(['git', 'ls-remote', $remote], true);
        if (1 >= ($exists = preg_match_all('#(?<=\s)'.preg_quote('refs/heads/'.$branch, '#').'(?!\w)$#m', $result))) {
            return 1 === $exists;
        }

        throw new \RuntimeException(sprintf('Invalid refs found while searching for remote branch at "refs/heads/%s"', $branch));
    }
827659
public function getPath(string $ref)
    {
        $properties     = $this->getProperties();
        $optionsPath    = $properties['optionsPath'];

        return array_key_exists($ref, $optionsPath) ? $optionsPath[$ref] : false;
    }
32844
public function findReferencesTo($symbol)
    {
        $locations = $this->codebase->findReferencesToSymbol($symbol);

        foreach ($locations as $location) {
            $snippet = $location->getSnippet();

            $snippet_bounds = $location->getSnippetBounds();
            $selection_bounds = $location->getSelectionBounds();

            $selection_start = $selection_bounds[0] - $snippet_bounds[0];
            $selection_length = $selection_bounds[1] - $selection_bounds[0];

            echo $location->file_name . ':' . $location->getLineNumber() . "\n" .
                (
                    $this->use_color
                    ? substr($snippet, 0, $selection_start) .
                    "\e[97;42m" . substr($snippet, $selection_start, $selection_length) .
                    "\e[0m" . substr($snippet, $selection_length + $selection_start)
                    : $snippet
                ) . "\n" . "\n";
        }
    }
97855
public function resolve($reference)
    {
        if (empty($reference)) {
            return $reference;
        }

        if ($this->isResolvableAnonymousReference($reference)) {
            return $this->resolveAnonymousReference($reference);
        }

        return $this->resolveInternal($reference);
    }