From bb363dfe8a6c8cf7765ef25c059b0dab1bea2002 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 17 Aug 2022 18:08:44 +0200 Subject: [PATCH] wip #5399 @0.25 --- app/Console/Commands/FluidbookPullSources.php | 66 +++++++++++++++++++ app/Console/Kernel.php | 1 + 2 files changed, 67 insertions(+) create mode 100644 app/Console/Commands/FluidbookPullSources.php diff --git a/app/Console/Commands/FluidbookPullSources.php b/app/Console/Commands/FluidbookPullSources.php new file mode 100644 index 000000000..a87c244e1 --- /dev/null +++ b/app/Console/Commands/FluidbookPullSources.php @@ -0,0 +1,66 @@ +executeGitCommand($dir, $command); + } + return $res; + } + + protected function executeGitCommand($dir, $command) + { + $git = new Git($dir); + $output = $git->executeCmd($command); + + $this->line('' . $git->getCommand() . ''); + $this->line($output); + return $output; + } + + public function handle() + { + PHP::neverStop(true); + + $playerDir = Files::mkdir(resource_path('fluidbookpublication/player')) . '/'; + $branchesDir = Files::mkdir($playerDir . 'branches/'); + $localDir = Files::mkdir($playerDir . 'local/'); + $baseBranchDir = Files::mkdir($branchesDir . 'fluidbook-html5'); + + $this->executeGitCommands($baseBranchDir, ['stash save --keep-index', 'stash drop', 'pull --all', 'fetch --all --prune']); + + $git = new Git($baseBranchDir); + $branches = $git->listBranches(); + foreach ($branches as $b) { + $gitsource = $branchesDir . $b; + $local = $localDir . $b; + if (!file_exists($branchesDir . $b)) { + $this->executeGitCommands($branchesDir, 'clone -b ' . $b . ' --single-branch git@git.cubedesigners.com:fluidbook-html5.git ' . $b); + } + if (!file_exists($local)) { + mkdir($local, 0777, true); + `cp -r $gitsource/* $local`; + `rm -rf $local/.git`; + } + $this->executeGitCommands($branchesDir . $b, ['reset --hard origin/' . $b, 'pull']); + } + file_put_contents($playerDir . '/activebranches', json_encode($branches)); + } + +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 1420f210b..1e2d58fe8 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -29,6 +29,7 @@ class Kernel extends \Cubist\Backpack\Console\Kernel $schedule->command('cubist:magic:precache')->everyFiveMinutes(); $schedule->command('job:dispatch ProcessTotals')->everyTwoHours(); $schedule->command('fluidbook:farm:ping')->everyMinute(); + $schedule->command('fluidbook:player:updatesources')->everyMinute(); } -- 2.39.5