in src/importit/filter/ImportItSubmoduleFilter.php [75:117]
public static function moveSubmoduleCommitToTextFile(
ShipItChangeset $changeset,
string $submodule_path,
string $text_file_with_rev,
): ShipItChangeset {
$diffs = vec[];
foreach ($changeset->getDiffs() as $diff) {
$path = $diff['path'];
$body = $diff['body'];
if ($path !== $submodule_path) {
$diffs[] = $diff;
continue;
}
$new_rev = null;
$old_rev = null;
foreach (Str\split($body, "\n") as $line) {
if (Str\starts_with($line, '-Subproject commit ')) {
$old_rev = Str\trim(Str\slice($line, 19));
} else if (Str\starts_with($line, '+Subproject commit ')) {
$new_rev = Str\trim(Str\slice($line, 19));
}
}
$changeset = $changeset
->withDebugMessage(
'Updating submodule at %s (external path %s) to %s (from %s)',
$text_file_with_rev,
$submodule_path,
$new_rev ?? 'null',
$old_rev ?? 'null',
);
$diffs[] = shape(
'path' => $text_file_with_rev,
'body' =>
self::makeSubmoduleDiff($text_file_with_rev, $old_rev, $new_rev),
);
}
return $changeset->withDiffs($diffs);
}