From d568ba7a2883893a35ad39b5d6f9a88a860b694a Mon Sep 17 00:00:00 2001 From: Sarah Mount Date: Mon, 18 Sep 2023 08:33:13 +0100 Subject: [PATCH] Generated app can be deployed Whippet expects that a deployable app is a Git repo, with at least one commit. Previously, an app generated by Whippet was a Git repo, but did not have any commits, and so could not be deployed. This commit adds a single commit to generated apps, to fix that. Fixes #47 --- CHANGELOG.md | 3 +++ generators/app/generate.php | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c8a3a0..8f4193a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- `whippet generate app` generates an app which can be deployed by Whippet. + ### Added - Support for PHP 8 diff --git a/generators/app/generate.php b/generators/app/generate.php index 12fca74..58bf529 100644 --- a/generators/app/generate.php +++ b/generators/app/generate.php @@ -25,7 +25,8 @@ function generate() { } // Make the target dir a git repo, if it isn't already - if(!(new \Dxw\Whippet\Git\Git($this->target_dir))->is_repo()) { + $target_repo = new \Dxw\Whippet\Git\Git($this->target_dir); + if(!$target_repo->is_repo()) { \Dxw\Whippet\Git\Git::init($this->target_dir); } @@ -35,6 +36,12 @@ function generate() { $this->unzipAndRemoveTemplateZip(); + // Whippet deploy requires at least one commit in the repo. + if (!$target_repo->current_commit()) { + $target_repo->add("--all"); + $target_repo->commit("Initial commit from Whippet"); + } + if(isset($this->options->repository)) { $this->setWPRepository(); }