From 3e36d718f58894ee50139f367dbdb1029cfe31ea Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Dec 2024 17:30:46 +0100 Subject: [PATCH] Add coloring to make output easier to read --- .github/bin/pick.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/bin/pick.php b/.github/bin/pick.php index f9a8d201..c4ca68d0 100644 --- a/.github/bin/pick.php +++ b/.github/bin/pick.php @@ -5,8 +5,9 @@ // Check if we have the correct number of arguments if ($argc !== 3) { - echo "Usage: php bin/pick.php \n"; - echo "Example: php bin/pick.php abc123 feature-branch\n"; + echo "\033[31mError: Invalid number of arguments\033[0m\n"; + echo "\033[1mUsage:\033[0m php bin/pick.php \n"; + echo "\033[1mExample:\033[0m php bin/pick.php abc123 feature-branch\n"; exit(1); } @@ -16,23 +17,25 @@ // Create new branch from master $checkoutCommand = "git checkout -b $branch master"; +echo "\033[36m> $checkoutCommand\033[0m\n"; exec($checkoutCommand, $output, $returnCode); if ($returnCode !== 0) { - echo "Error creating new branch: $branch\n"; + echo "\033[31mError creating new branch: $branch\033[0m\n"; exit(1); } // Cherry-pick the commit $cherryPickCommand = "git cherry-pick $hash"; +echo "\033[36m> $cherryPickCommand\033[0m\n"; exec($cherryPickCommand, $output, $returnCode); if ($returnCode !== 0) { - echo "Error cherry-picking commit: $hash\n"; + echo "\033[31mError cherry-picking commit: $hash\033[0m\n"; exit(1); } -echo "Successfully created branch '$branch' and cherry-picked commit '$hash'\n"; +echo "\033[32mSuccessfully created branch '$branch' and cherry-picked commit '$hash'\033[0m\n"; // Get the commit message $command = "git show $hash --pretty=format:\"%s%n%b\" -s"; @@ -47,8 +50,8 @@ $prNumber = $matches[1]; $title = trim($matches[2]); - echo "\nSuggested PR format:\n"; - echo "Title: $title\n"; - echo "Description: Merges pull request https://github.com/hydephp/develop/pull/$prNumber\n"; + echo "\n\033[1mSuggested PR format:\033[0m\n"; + echo "\033[1mTitle:\033[0m $title\n"; + echo "\033[1mDescription:\033[0m Merges pull request https://github.com/hydephp/develop/pull/$prNumber\n"; } }