Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
Move implementation of timing logs out of ShipIt
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bigfootjon authored and facebook-github-bot committed Apr 24, 2023
1 parent 0f6cc1a commit e5a574b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
32 changes: 22 additions & 10 deletions src/shipit/ShipItSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ final class ShipItSync {
'timestamp' => ?int,
'branch' => string,
),
'changesets' => vec<string>,
'skipped' => vec<string>,
'changesets' => vec<shape(
'id' => string,
'timestamp' => int,
)>,
'skipped' => vec<shape(
'id' => string,
'timestamp' => int,
)>,
);

public function __construct(
Expand Down Expand Up @@ -216,10 +222,6 @@ public function __construct(
vec<ShipItChangeset> $changesets_applied,
vec<ShipItChangeset> $changesets_skipped,
): Awaitable<void> {
$stats_function = $this->syncConfig->getStatsFunction();
if ($stats_function is nonnull) {
$stats_function($changesets_applied, $changesets_skipped);
}
$filename = $this->syncConfig->getStatsFilename();
if ($filename === null) {
return;
Expand Down Expand Up @@ -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(),
),
),
),
);
}
Expand Down
18 changes: 0 additions & 18 deletions src/shipit/ShipItSyncConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@ final class ShipItSyncConfig {
vec<ShipItChangeset>,
IShipItRepo,
): Awaitable<vec<ShipItChangeset>>);
const type TStatsFn = (function(
vec<ShipItChangeset>,
vec<ShipItChangeset>,
): void);

private ?string $firstCommit = null;
private keyset<string> $skippedSourceCommits = keyset[];
private ?string $patchesDirectory = null;
private keyset<string> $destinationRoots = keyset[];
private ?string $statsFilename = null;
private ?self::TStatsFn $statsFunction = null;
private bool $allowEmptyCommit = false;
private bool $doSubmodules = true;
private bool $nativeRenames = false;
Expand Down Expand Up @@ -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 ==> {
Expand Down
2 changes: 0 additions & 2 deletions src/shipit/phase/ShipItSyncPhase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function __construct(
private ?ShipItSyncConfig::TPostFilterChangesetsFn $postFilterChangesets =
null,
private bool $allowEmptyCommit = false,
private ?ShipItSyncConfig::TStatsFn $statsFunction = null,
) {}

<<__Override>>
Expand Down Expand Up @@ -126,7 +125,6 @@ public function getCLIArguments(): vec<ShipItCLIArgument> {
->withSkippedSourceCommits($this->skippedSourceCommits)
->withPatchesDirectory($this->patchesDirectory)
->withStatsFilename($this->statsFilename)
->withStatsFunction($this->statsFunction)
->withAllowEmptyCommits($this->allowEmptyCommit)
->withShouldDoSubmodules($this->shouldDoSubmodules)
->withNativeRenames($this->nativeRenames);
Expand Down

0 comments on commit e5a574b

Please sign in to comment.