From 61e577046f8eb29b063fcb6b173d5e0c8f031efe Mon Sep 17 00:00:00 2001 From: Rafik Abdulwahab Date: Mon, 3 Apr 2023 12:17:27 +0100 Subject: [PATCH 1/2] add an option for setting a commit message --- src/Actions/CodeUpAction.php | 4 +++- src/Plugin.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Actions/CodeUpAction.php b/src/Actions/CodeUpAction.php index 4a4fadb..36b909d 100644 --- a/src/Actions/CodeUpAction.php +++ b/src/Actions/CodeUpAction.php @@ -18,6 +18,8 @@ class CodeUpAction extends StageAwareBaseAction { + public string $commitMessage = "init Craft"; + public function __construct( string $id, Commands $controller, @@ -92,7 +94,7 @@ public function run(?string $stage = null): int if ($status = $git->getWorkingCopy()->getStatus()) { // Changed files $this->noteBlock('Uncommitted changes:' . PHP_EOL . $status); - $defaultMessage = $this->interactive ? null : 'init Craft'; + $defaultMessage = $this->interactive ? null : $this->commitMessage; if (! $msg = $this->ask( 'Enter a commit message, or leave it empty to abort the commit', diff --git a/src/Plugin.php b/src/Plugin.php index 078adaf..d96575a 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -125,6 +125,7 @@ private function registerConsoleCommands(): void 'a' => 'app', 'e' => 'env', 'f' => 'force', + 'm' => 'commitMessage', ]; $group = (new ActionGroup('copy', 'Copy Craft between environments.')) From 7b742df0962bb331959a1ebe0bf90ee12999101d Mon Sep 17 00:00:00 2001 From: Rafik Abdulwahab Date: Tue, 4 Apr 2023 11:14:22 +0100 Subject: [PATCH 2/2] address empty commit message --- src/Actions/CodeUpAction.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Actions/CodeUpAction.php b/src/Actions/CodeUpAction.php index 36b909d..1693500 100644 --- a/src/Actions/CodeUpAction.php +++ b/src/Actions/CodeUpAction.php @@ -94,7 +94,13 @@ public function run(?string $stage = null): int if ($status = $git->getWorkingCopy()->getStatus()) { // Changed files $this->noteBlock('Uncommitted changes:' . PHP_EOL . $status); - $defaultMessage = $this->interactive ? null : $this->commitMessage; + + $commitMessage = $this->commitMessage; + if ($this->commitMessage == "1") { + $commitMessage = "init Craft"; + } + + $defaultMessage = $this->interactive ? null : $commitMessage; if (! $msg = $this->ask( 'Enter a commit message, or leave it empty to abort the commit',