From 7d744ded1919cf191b7facccbb9a9de567ce3a9d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 21 Dec 2024 20:20:57 +0100 Subject: [PATCH] Sync back with framework subpackage --- RELEASE_NOTES.md | 1 + packages/framework/.github/bin/pick.php | 58 +++++++++++++++++++ .../src/Support/Filesystem/MediaFile.php | 2 +- 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 packages/framework/.github/bin/pick.php diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e2f970a3d27..d0222bf5e85 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -15,6 +15,7 @@ This serves two purposes: - Added a new `Hyperlinks::isRemote()` helper method to check if a URL is remote in https://github.com/hydephp/develop/pull/1882 - All page types now support the `description` front matter field (used in page metadata) in https://github.com/hydephp/develop/pull/1884 - Added a new `Filesystem::findFiles()` method to find files in a directory in https://github.com/hydephp/develop/pull/2064 +- Added `webp` to the list of default media extensions in https://github.com/hydephp/framework/pull/663 ### Changed - Changed the `Hyde` facade to use a `@mixin` annotation instead of single method annotations in https://github.com/hydephp/develop/pull/1919 diff --git a/packages/framework/.github/bin/pick.php b/packages/framework/.github/bin/pick.php new file mode 100644 index 00000000000..c0303b09101 --- /dev/null +++ b/packages/framework/.github/bin/pick.php @@ -0,0 +1,58 @@ +#!/usr/bin/env php + [--pretend]\n"; + echo "\033[33mExample:\033[0m php bin/pick.php abc123 feature-branch\n"; + exit(1); +} + +// Get arguments +$hash = $argv[1]; +$branch = $argv[2]; +$pretend = ($argv[3] ?? false) === '--pretend'; + +// Get the commit message +exec("git show $hash --pretty=format:\"%s%n%b\" -s", $output, $returnCode); + +if ($returnCode === 0 && !empty($output)) { + $commitMessage = implode("\n", $output); + + // Check if this matches the subrepo sync format + if (preg_match('/^Merge pull request #(\d+).*\n(.*?)https:\/\/github\.com\/hydephp\/develop\/commit/', $commitMessage, $matches)) { + $prNumber = $matches[1]; + $title = trim($matches[2]); + $body = "Merges pull request https://github.com/hydephp/develop/pull/$prNumber"; + + $printWhenDone = "\n\033[33mSuggested PR format: (Line 1: title, Line 2: description, Line 3: command)\033[0m\n"; + $printWhenDone .= "$title\n$body\n"; + + $printWhenDone .= "\033[37mgh pr create --title \"$title\" --body \"$body\"\033[0m\n"; + } +} + +// Create new branch from master +exec(($pretend ? 'echo ' : '') . "git checkout -b $branch master", $output, $returnCode); + +if ($returnCode !== 0) { + echo "\033[31mError creating new branch: $branch\033[0m\n"; + exit(1); +} + +// Cherry-pick the commit +exec(($pretend ? 'echo ' : '') . "git cherry-pick $hash", $output, $returnCode); + +if ($returnCode !== 0) { + echo "\033[31mError cherry-picking commit: $hash\033[0m\n"; + exit(1); +} + +echo "\033[32mSuccessfully created branch '$branch' and cherry-picked commit '$hash'\033[0m\n"; + +if (isset($printWhenDone)) { + echo $printWhenDone; +} diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index 09ab5247ad6..8574c4ed07a 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -25,7 +25,7 @@ class MediaFile extends ProjectFile { /** @var array The default extensions for media types */ - final public const EXTENSIONS = ['png', 'svg', 'jpg', 'jpeg', 'gif', 'ico', 'css', 'js']; + final public const EXTENSIONS = ['png', 'svg', 'jpg', 'jpeg', 'webp', 'gif', 'ico', 'css', 'js']; /** @return array The array keys are the filenames relative to the _media/ directory */ public static function all(): array