From e5a574b974beedb3e33297d5de6c38d2b2f7019b Mon Sep 17 00:00:00 2001 From: Jon Janzen Date: Mon, 24 Apr 2023 10:26:16 -0700 Subject: [PATCH] Move implementation of timing logs out of ShipIt Summary: If this isn't in here then we don't need to migrate it to CodeSync! Reviewed By: jailby Differential Revision: D45132671 fbshipit-source-id: 6313fced624519f9f32a903c294da25b6dbeb964 --- src/shipit/ShipItSync.php | 32 +++++++++++++++++++--------- src/shipit/ShipItSyncConfig.php | 18 ---------------- src/shipit/phase/ShipItSyncPhase.php | 2 -- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/shipit/ShipItSync.php b/src/shipit/ShipItSync.php index 73edea4a..cb879b92 100644 --- a/src/shipit/ShipItSync.php +++ b/src/shipit/ShipItSync.php @@ -35,8 +35,14 @@ final class ShipItSync { 'timestamp' => ?int, 'branch' => string, ), - 'changesets' => vec, - 'skipped' => vec, + 'changesets' => vec string, + 'timestamp' => int, + )>, + 'skipped' => vec string, + 'timestamp' => int, + )>, ); public function __construct( @@ -216,10 +222,6 @@ public function __construct( vec $changesets_applied, vec $changesets_skipped, ): Awaitable { - $stats_function = $this->syncConfig->getStatsFunction(); - if ($stats_function is nonnull) { - $stats_function($changesets_applied, $changesets_skipped); - } $filename = $this->syncConfig->getStatsFilename(); if ($filename === null) { return; @@ -250,10 +252,20 @@ public function __construct( 'timestamp' => $destination_changeset?->getTimestamp(), 'branch' => $destination_branch, ), - 'changesets' => - Vec\map($changesets_applied, $changeset ==> $changeset->getID()), - 'skipped' => - Vec\map($changesets_skipped, $changeset ==> $changeset->getID()), + 'changesets' => Vec\map( + $changesets_applied, + $changeset ==> shape( + 'id' => $changeset->getID(), + 'timestamp' => $changeset->getTimestamp(), + ), + ), + 'skipped' => Vec\map( + $changesets_skipped, + $changeset ==> shape( + 'id' => $changeset->getID(), + 'timestamp' => $changeset->getTimestamp(), + ), + ), ), ); } diff --git a/src/shipit/ShipItSyncConfig.php b/src/shipit/ShipItSyncConfig.php index ce357b79..6910f0ab 100644 --- a/src/shipit/ShipItSyncConfig.php +++ b/src/shipit/ShipItSyncConfig.php @@ -21,17 +21,12 @@ final class ShipItSyncConfig { vec, IShipItRepo, ): Awaitable>); - const type TStatsFn = (function( - vec, - vec, - ): void); private ?string $firstCommit = null; private keyset $skippedSourceCommits = keyset[]; private ?string $patchesDirectory = null; private keyset $destinationRoots = keyset[]; private ?string $statsFilename = null; - private ?self::TStatsFn $statsFunction = null; private bool $allowEmptyCommit = false; private bool $doSubmodules = true; private bool $nativeRenames = false; @@ -133,19 +128,6 @@ public function withStatsFilename(?string $filename): this { ); } - public function getStatsFunction(): ?self::TStatsFn { - return $this->statsFunction; - } - - public function withStatsFunction(?self::TStatsFn $function): this { - return $this->modified( - $ret ==> { - $ret->statsFunction = $function; - return $ret->statsFunction; - }, - ); - } - public function withAllowEmptyCommits(bool $allow_empty_commit): this { return $this->modified( $ret ==> { diff --git a/src/shipit/phase/ShipItSyncPhase.php b/src/shipit/phase/ShipItSyncPhase.php index 6793c25f..399b6e63 100644 --- a/src/shipit/phase/ShipItSyncPhase.php +++ b/src/shipit/phase/ShipItSyncPhase.php @@ -28,7 +28,6 @@ public function __construct( private ?ShipItSyncConfig::TPostFilterChangesetsFn $postFilterChangesets = null, private bool $allowEmptyCommit = false, - private ?ShipItSyncConfig::TStatsFn $statsFunction = null, ) {} <<__Override>> @@ -126,7 +125,6 @@ public function getCLIArguments(): vec { ->withSkippedSourceCommits($this->skippedSourceCommits) ->withPatchesDirectory($this->patchesDirectory) ->withStatsFilename($this->statsFilename) - ->withStatsFunction($this->statsFunction) ->withAllowEmptyCommits($this->allowEmptyCommit) ->withShouldDoSubmodules($this->shouldDoSubmodules) ->withNativeRenames($this->nativeRenames);