Skip to content

Commit

Permalink
[ Fix ] Update command creates hooks as non-executable (#82)
Browse files Browse the repository at this point in the history
* remove deprecated binary reference

* update command should ensure hooks are executable

* lint

* update php version to 8.4 in CI

* increase memory limit in stan script

* update legacy GH actions set-output

* revert to legacy set-output in test.yml
  • Loading branch information
ProjektGopher authored Feb 25, 2025
1 parent 6f0fc83 commit e8d2ee5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/larastan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
operating-system:
- ubuntu-latest
php-version:
- "8.2"
- "8.4"
name: php ${{ matrix.php-version }} on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
steps:
Expand All @@ -22,7 +22,7 @@ jobs:
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Setup composer cache
uses: actions/cache@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
operating-system:
- ubuntu-latest
php-version:
- "8.2"
- "8.4"
name: php ${{ matrix.php-version }} on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
steps:
Expand All @@ -20,12 +20,12 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
php-version: "8.4"
extensions: bcmath, ctype, fileinfo, json, mbstring, openssl, pdo, tokenizer, xml
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Setup composer cache
uses: actions/cache@v4
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
name: php ${{ matrix.php-version }} on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
operating-system:
- ubuntu-latest
php-version:
- "8.2"
- "8.4"
name: php ${{ matrix.php-version }} on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
steps:
Expand All @@ -22,7 +22,7 @@ jobs:
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Setup composer cache
uses: actions/cache@v4
with:
Expand Down
1 change: 0 additions & 1 deletion app/Commands/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public function handle(): int
$this->info('Verifying hooks are executable...');
}
exec('chmod +x '.Platform::cwd('.git/hooks').'/*');
exec('chmod +x '.Whisky::base_path('bin/run-hook'));
}

$this->info('Git hooks installed successfully.');
Expand Down
16 changes: 15 additions & 1 deletion app/Commands/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use LaravelZero\Framework\Commands\Command;
use ProjektGopher\Whisky\Hook;
use ProjektGopher\Whisky\Platform;

/**
* TODO: This has a lot of duplication wrt Commands\Uninstall and Commands\Install.
Expand All @@ -14,6 +15,12 @@ class Update extends Command

protected $description = 'Update git hooks';

public function __construct(
public Platform $platform,
) {
parent::__construct();
}

public function handle(): int
{
Hook::all(Hook::FROM_GIT)->each(function (Hook $hook): void {
Expand Down Expand Up @@ -42,7 +49,14 @@ public function handle(): int
}
});

$this->line('done.');
if ($this->platform->isNotWindows()) {
if ($this->option('verbose')) {
$this->info('Verifying hooks are executable...');
}
exec('chmod +x '.Platform::cwd('.git/hooks').'/*');
}

$this->line('Git hooks updated successfully.');

return Command::SUCCESS;
}
Expand Down
6 changes: 3 additions & 3 deletions app/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ public function getSnippets(): Collection
]);
}

////////////////////////////////////////
//// Static methods ////
////////////////////////////////////////
// //////////////////////////////////////
// // Static methods ////
// //////////////////////////////////////

/**
* Static Constructor.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"vendor/bin/pint"
],
"stan": [
"vendor/bin/phpstan analyse"
"vendor/bin/phpstan analyse --memory-limit=1G"
],
"test": [
"@php whisky test"
Expand Down

0 comments on commit e8d2ee5

Please sign in to comment.