protected async function genRunImpl()

in src/shipit/phase/ShipItVerifyRepoPhase.php [204:280]


  protected async function genRunImpl(
    ShipItManifest $manifest,
  ): Awaitable<void> {
    $results = await static::genVerifyRepo(shape(
      'manifest' => $manifest,
      'genFilter' => $this->genFilter,
      'useLatestSourceCommit' => $this->useLatestSourceCommit,
      'verifySourceCommit' => $this->verifySourceCommit,
      'shouldDoSubmodules' => $this->shouldDoSubmodules,
      'createPatch' => $this->createPatch,
    ));
    $diffstat = $results['diffstat'];
    $diff = $results['patch'];

    if ($diffstat === '') {
      if ($this->createPatch) {
        ShipItLogger::err(
          "  CREATE PATCH FAILED: destination is already in sync.\n",
        );
        throw new ShipItExitException(1);
      }
      ShipItLogger::out("  Verification OK: destination is in sync.\n");
      throw new ShipItExitException(0);
    }

    if (!$this->createPatch) {
      ShipItLogger::err(
        "  VERIFICATION FAILED: destination repo does not match:\n\n%s\n",
        $diffstat,
      );
      throw new ShipItExitException(1);
    }

    $source_sync_id = $this->verifySourceCommit;
    if ($source_sync_id === null) {
      $repo = await ShipItRepo::genTypedOpen<ShipItSourceRepo>(
        $manifest->getSourceSharedLock(),
        $manifest->getSourcePath(),
        $manifest->getSourceBranch(),
      );
      $changeset = await $repo->genHeadChangeset();
      if ($changeset === null) {
        throw new ShipItException('Could not find source id.');
      }
      $source_sync_id = $changeset->getID();
    }

    $patch_file = PHP\tempnam(PHP\sys_get_temp_dir(), 'shipit-resync-patch-')
      as string;
    PHP\file_put_contents($patch_file, $diff);

    ShipItLogger::out(
      "  Created patch file: %s\n\n".
      "%s\n\n".
      "  To apply:\n\n".
      "    $ cd %s\n".
      "    $ git apply < %s\n".
      "    $ git status\n".
      "    $ git add --all --patch\n".
      "    $ git commit -m '%s: %s'\n".
      "    $ git push\n\n".
      "  WARNING: there are 4 possible causes for differences:\n\n".
      "    1. changes in source haven't been copied to destination\n".
      "    2. changes were made to destination that aren't in source\n".
      "    3. the filter function has a bug\n".
      "    4. FBShipIt has a bug\n\n".
      "  APPLYING THE PATCH IS ONLY CORRECT FOR THE FIRST SITUATION; review\n".
      "  the changes carefully.\n\n",
      $patch_file,
      $diffstat,
      $manifest->getDestinationPath(),
      $patch_file,
      $manifest->getCommitMarker(),
      $source_sync_id,
    );
    throw new ShipItExitException(0);
  }