public async function genRun()

in src/shipit/ShipItSync.php [107:192]


  public async function genRun(): Awaitable<void> {
    $changesets = await $this->genFilteredChangesets();
    if (C\is_empty($changesets)) {
      ShipItLogger::out("  No new commits to sync.\n");
      await $this->genMaybeLogStats(vec[], vec[]);
      return;
    }

    $patches_dir = $this->syncConfig->getPatchesDirectory();
    if ($patches_dir !== null && !PHP\file_exists($patches_dir)) {
      PHP\mkdir($patches_dir, 0755, /* recursive = */ true);
    }

    $verbose = $this->manifest->isVerboseEnabled();
    $dest = await $this->genRepo<ShipItDestinationRepo>();

    $changesets = await $this->syncConfig
      ->genPostFilterChangesets($changesets, $dest);

    $changesets_applied = vec[];
    $changesets_skipped = vec[];
    foreach ($changesets as $changeset) {
      if ($patches_dir !== null) {
        $file = $patches_dir.
          '/'.
          $this->manifest->getDestinationBranch().
          '-'.
          $changeset->getID().
          '.patch';
        if (PHP\file_exists($file)) {
          ShipItLogger::out("Overwriting patch file: %s\n", $file);
        }
        PHP\file_put_contents($file, $dest::renderPatch($changeset));
        $changeset =
          $changeset->withDebugMessage('Saved patch file: %s', $file);
      }

      if ($verbose) {
        $changeset->dumpDebugMessages();
      }

      if (!$this->isValidChangeToSync($changeset)) {
        ShipItLogger::out(
          "  SKIP %s %s\n",
          $changeset->getShortID(),
          $changeset->getSubject(),
        );
        $changesets_skipped[] = $changeset;
        continue;
      }

      try {
        // @lint-ignore AWAIT_IN_LOOP These need to be committed one at a time
        await $dest->genCommitPatch(
          $changeset,
          $this->syncConfig->getShouldDoSubmodules(),
        );
        ShipItLogger::out(
          "  OK %s %s\n",
          $changeset->getShortID(),
          $changeset->getSubject(),
        );
        $changesets_applied[] = $changeset;
        continue;
      } catch (ShipItRepoException $e) {
        ShipItLogger::err(
          "Failed to apply patch %s (%s): %s\n",
          $changeset->getID(),
          $changeset->getMessage(),
          $e->getMessage(),
        );
        throw $e;
      } catch (\Exception $e) {
        ShipItLogger::err(
          "  !! %s ERROR: sync failed:\n",
          $changeset->getShortID(),
        );
        if ($verbose) {
          ShipItLogger::err("%s\n", ShipItRepoGIT::renderPatch($changeset));
        }
        throw $e;
      }
    }

    await $this->genMaybeLogStats($changesets_applied, $changesets_skipped);
  }