<commit_before><?php

final class PhabricatorRepositoryRepositoryPHIDType
  extends PhabricatorPHIDType {

  const TYPECONST = 'REPO';

  public function getTypeName() {
    return pht('Repository');
  }

  public function getTypeIcon() {
    return 'fa-code';
  }

  public function newObject() {
    return new PhabricatorRepository();
  }

  public function getPHIDTypeApplicationClass() {
    return 'PhabricatorDiffusionApplication';
  }

  protected function buildQueryForObjects(
    PhabricatorObjectQuery $query,
    array $phids) {

    return id(new PhabricatorRepositoryQuery())
      ->withPHIDs($phids);
  }

  public function loadHandles(
    PhabricatorHandleQuery $query,
    array $handles,
    array $objects) {

    foreach ($handles as $phid => $handle) {
      $repository = $objects[$phid];

      $monogram = $repository->getMonogram();
      $name = $repository->getName();
      $uri = $repository->getURI();

      $handle
        ->setName($monogram)
        ->setFullName("{$monogram} {$name}")
        ->setURI($uri)
        ->setMailStampName($monogram);
    }
  }

  public function canLoadNamedObject($name) {
    return preg_match('/^(r[A-Z]+|R[1-9]\d*)\z/', $name);
  }

  public function loadNamedObjects(
    PhabricatorObjectQuery $query,
    array $names) {

    $results = array();
    $id_map = array();
    foreach ($names as $key => $name) {
      $id = substr($name, 1);
      $id_map[$id][] = $name;
      $names[$key] = substr($name, 1);
    }

    $query = id(new PhabricatorRepositoryQuery())<commit_msg>When a repository is inactive, mark its handle as "closed"<commit_after><?php

final class PhabricatorRepositoryRepositoryPHIDType
  extends PhabricatorPHIDType {

  const TYPECONST = 'REPO';

  public function getTypeName() {
    return pht('Repository');
  }

  public function getTypeIcon() {
    return 'fa-code';
  }

  public function newObject() {
    return new PhabricatorRepository();
  }

  public function getPHIDTypeApplicationClass() {
    return 'PhabricatorDiffusionApplication';
  }

  protected function buildQueryForObjects(
    PhabricatorObjectQuery $query,
    array $phids) {

    return id(new PhabricatorRepositoryQuery())
      ->withPHIDs($phids);
  }

  public function loadHandles(
    PhabricatorHandleQuery $query,
    array $handles,
    array $objects) {

    foreach ($handles as $phid => $handle) {
      $repository = $objects[$phid];

      $monogram = $repository->getMonogram();
      $name = $repository->getName();
      $uri = $repository->getURI();

      $handle
        ->setName($monogram)
        ->setFullName("{$monogram} {$name}")
        ->setURI($uri)
        ->setMailStampName($monogram);

      if ($repository->getStatus() !== PhabricatorRepository::STATUS_ACTIVE) {
        $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
      }
    }
  }

  public function canLoadNamedObject($name) {
    return preg_match('/^(r[A-Z]+|R[1-9]\d*)\z/', $name);
  }

  public function loadNamedObjects(
    PhabricatorObjectQuery $query,
    array $names) {

    $results = array();
    $id_map = array();
    foreach ($names as $key => $name) {
      $id = substr($name, 1);
      $id_map[$id][] = $name;
      $names[$key] = substr($name, 1);
    }

    $query = id(new PhabricatorRepositoryQuery())
{'fraction_non_alphanumeric': 0.14130105900151285, 'fraction_numerical': 0.002420574886535552, 'mean_word_length': 3.2935064935064937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6126596', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1040, 'n_words': 216}