更新
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
// Run from the project checkout: php server/scripts/install_tcm_ancient_books.php
|
||||
// The upstream corpus is fetched directly into this deployment. Its source text
|
||||
// is intentionally not committed to this application's repository.
|
||||
// Initialize the pinned corpus submodule and build its local search index.
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
@@ -16,6 +15,7 @@ if (PHP_SAPI !== 'cli') {
|
||||
}
|
||||
|
||||
$root = dirname(__DIR__) . '/knowledge/tcm-ancient-books';
|
||||
$projectRoot = dirname(__DIR__, 2);
|
||||
$indexPath = TcmAncientBooksReference::indexPath();
|
||||
|
||||
function runGit(array $arguments): string
|
||||
@@ -31,8 +31,18 @@ function runGit(array $arguments): string
|
||||
}
|
||||
|
||||
try {
|
||||
if (!is_dir($root)) {
|
||||
runGit(['clone', '--depth', '1', TcmAncientBooksReference::REPOSITORY_URL . '.git', $root]);
|
||||
if (!is_dir($root . '/.git') && !is_file($root . '/.git')) {
|
||||
if (is_file($projectRoot . '/.gitmodules')
|
||||
&& (is_dir($projectRoot . '/.git') || is_file($projectRoot . '/.git'))) {
|
||||
runGit(['-C', $projectRoot, 'submodule', 'update', '--init', '--', 'server/knowledge/tcm-ancient-books']);
|
||||
} else {
|
||||
runGit(['clone', '--depth', '1', TcmAncientBooksReference::REPOSITORY_URL . '.git', $root]);
|
||||
}
|
||||
}
|
||||
$checkoutRoot = runGit(['-C', $root, 'rev-parse', '--show-toplevel']);
|
||||
if (strtolower(str_replace('\\', '/', (string) realpath($checkoutRoot)))
|
||||
!== strtolower(str_replace('\\', '/', (string) realpath($root)))) {
|
||||
throw new RuntimeException('Corpus checkout is missing or points to the parent repository');
|
||||
}
|
||||
$head = runGit(['-C', $root, 'rev-parse', 'HEAD']);
|
||||
if ($head !== TcmAncientBooksReference::COMMIT) {
|
||||
|
||||
Reference in New Issue
Block a user