Skip to content

Commit

Permalink
Merge pull request #2069 from hydephp/sync-back-with-framework
Browse files Browse the repository at this point in the history
Sync back with the Framework subpackage
  • Loading branch information
caendesilva authored Dec 21, 2024
2 parents 6a13d76 + 7d744de commit ce23e41
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions packages/framework/.github/bin/pick.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env php
<?php

// Internal helper to speed up branching up cherry picked commits for pull requests

// Check if we have the correct number of arguments
if ($argc !== 3 && $argc !== 4) {
echo "\033[31mError: Invalid number of arguments\033[0m\n";
echo "\033[33mUsage:\033[0m php bin/pick.php <commit-hash> <branch-name> [--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;
}
2 changes: 1 addition & 1 deletion packages/framework/src/Support/Filesystem/MediaFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class MediaFile extends ProjectFile
{
/** @var array<string> 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<string, \Hyde\Support\Filesystem\MediaFile> The array keys are the filenames relative to the _media/ directory */
public static function all(): array
Expand Down

0 comments on commit ce23e41

Please sign in to comment.