in src/shipit/filter/ShipItSubmoduleFilter.php [79:111]
public static function useSubmoduleCommitFromTextFile(
ShipItChangeset $changeset,
string $text_file_with_rev,
string $submodule_path,
): ShipItChangeset {
$diffs = vec[];
foreach ($changeset->getDiffs() as $diff) {
$path = $diff['path'];
$body = $diff['body'];
if ($path !== $text_file_with_rev) {
$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));
}
}
$diffs[] = shape(
'path' => $submodule_path,
'body' => self::makeSubmoduleDiff($submodule_path, $old_rev, $new_rev),
);
}
return $changeset->withDiffs($diffs);
}