Skip to content

Commit

Permalink
Add coloring to make output easier to read
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 21, 2024
1 parent 80d23b7 commit 3e36d71
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .github/bin/pick.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

// Check if we have the correct number of arguments
if ($argc !== 3) {
echo "Usage: php bin/pick.php <commit-hash> <new-branch-name>\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 <commit-hash> <new-branch-name>\n";
echo "\033[1mExample:\033[0m php bin/pick.php abc123 feature-branch\n";
exit(1);
}

Expand All @@ -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";
Expand All @@ -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";
}
}

0 comments on commit 3e36d71

Please sign in to comment.