Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: botble/git-commit-checker
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0.1
Choose a base ref
...
head repository: botble/git-commit-checker
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 14 commits
  • 9 files changed
  • 2 contributors

Commits on Jan 5, 2023

  1. Copy the full SHA
    e76fc87 View commit details

Commits on Jan 6, 2023

  1. Copy the full SHA
    723162c View commit details
  2. Update CHANGELOG.md

    dinhquochan authored Jan 6, 2023
    Copy the full SHA
    49c60f0 View commit details
  3. Fix various bugs (#11)

    dinhquochan authored Jan 6, 2023
    Copy the full SHA
    048c6af View commit details
  4. Update CHANGELOG.md

    dinhquochan authored Jan 6, 2023
    Copy the full SHA
    afdb0fd View commit details
  5. Update README.md

    dinhquochan authored Jan 6, 2023
    Copy the full SHA
    997922f View commit details
  6. Copy the full SHA
    5b99d0b View commit details

Commits on Jan 11, 2023

  1. Update composer.json

    dinhquochan authored Jan 11, 2023
    Copy the full SHA
    d0d892f View commit details
  2. Update CHANGELOG.md

    dinhquochan authored Jan 11, 2023
    Copy the full SHA
    401a3c4 View commit details

Commits on Feb 12, 2023

  1. Copy the full SHA
    17d8075 View commit details

Commits on Feb 15, 2023

  1. Update composer.json

    sangnguyenplus authored Feb 15, 2023
    Copy the full SHA
    0b75b3c View commit details

Commits on Jun 29, 2024

  1. Update composer.json

    sangnguyenplus authored Jun 29, 2024
    Copy the full SHA
    31dea88 View commit details

Commits on Jul 31, 2024

  1. Update README.md

    sangnguyenplus committed Jul 31, 2024
    Copy the full SHA
    ffcae57 View commit details

Commits on Dec 14, 2024

  1. Update composer.json

    sangnguyenplus authored Dec 14, 2024
    Copy the full SHA
    3235de9 View commit details
23 changes: 16 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/.github export-ignore
/.editorconfig export-ignore
/pint.json export-ignore
* text=auto

*.blade.php diff=html
*.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php

/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
/.editorconfig export-ignore
/art export-ignore
/phpunit.xml.dist export-ignore
/pint.json export-ignore
/tests export-ignore
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Changelog

All notable changes to `laravel-git-commit-checker` will be documented in this file.
All notable changes to `botble/git-commit-checker` will be documented in this file.

## 2.1.2 - 2023-01-11

- Bump version `laravel/pint`

## 2.1.1 - 2023-01-06

- Fix various bugs

## 2.1.0 - 2023-01-06

- Fix output render on Windows platform (https://github.com/botble/git-commit-checker/pull/10)

## 2.0.1 - 2023-01-05

16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Laravel GIT Commit Checker

[![Latest Version](https://img.shields.io/packagist/v/botble/git-commit-checker.svg?style=flat-square)](https://github.com/botble/git-commit-checker/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Total Downloads](https://img.shields.io/packagist/dt/botble/git-commit-checker.svg?style=flat-square)](https://packagist.org/packages/botble/git-commit-checker)
[![Maintainability](https://api.codeclimate.com/v1/badges/a6e4612307e3b3bf8252/maintainability)](https://codeclimate.com/github/botble/git-commit-checker/maintainability)
<p align="center">
<img src="/art/overview.png" alt="Overview Git Commit Checker" style="width:70%;">
</p>

<p align="center">
<a href="https://packagist.org/packages/botble/git-commit-checker"><img src="https://img.shields.io/packagist/v/botble/git-commit-checker.svg?style=flat-square" alt="Latest Version"></a>
<a href="/LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square" alt="Software License"></a>
<a href="https://packagist.org/packages/botble/git-commit-checker"><img src="https://img.shields.io/packagist/dt/botble/git-commit-checker.svg?style=flat-square" alt="Total Downloads"></a>
<a href="https://codeclimate.com/github/botble/git-commit-checker/maintainability"><img src="https://api.codeclimate.com/v1/badges/a6e4612307e3b3bf8252/maintainability" alt="Maintainability"></a>
</p>

## Requirement

@@ -48,7 +54,7 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

If you discover any security related issues, please email contact@dinhquochan.com instead of using the issue tracker.
If you discover any security related issues, please email contact@botble.com instead of using the issue tracker.

## Credits

Binary file added art/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -27,12 +27,12 @@
}
},
"require": {
"php": "^8.0|^8.1|^8.2",
"laravel/framework": "^9.32|^10.0",
"laravel/pint": "^1.3.0"
"php": "^8.0|^8.1|^8.2|^8.3",
"laravel/framework": "^9.32|^10.0||^11.0",
"laravel/pint": "^1.5"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
"phpunit/phpunit": "^9.0|^10.0|^11.0"
},
"extra": {
"laravel": {
53 changes: 53 additions & 0 deletions resources/views/summary.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<div class="mx-2">
@if(! $isSuccessful)
@foreach($result['files'] as $file)
<div class="mb-1 mt-2">
<span class="px-1 bg-red text-white uppercase">File</span>
<span class="ml-1">{{ ltrim(str_replace(base_path(), '', $file['name']), DIRECTORY_SEPARATOR) }}</span>
</div>

<div class="flex max-w-150">
<span>Rules</span>
<span class="flex-1 content-repeat-[.] text-gray ml-1"></span>
<span class="ml-1">
@foreach($file['appliedFixers'] as $fixer)
<span class="text-red ml-1">{{ $fixer . ($loop->last ? '' : ', ') }}</span>
@endforeach
</span>
</div>

<div class="flex space-x-1 mt-1">
<span class="flex-1 content-repeat-[─] text-gray"></span>
</div>
@endforeach

<div class="mb-2"></div>
@endif

<div class="flex space-x-1 mb-2">
<span class="font-bold">
Checked <span class="text-yellow">{{ count($result['files']) }}</span> files in <span class="text-yellow">{{ $result['time']['total'] ?? 0 }}</span> seconds.
Using memory <span class="text-yellow">{{ $result['memory'] }}</span> MB.
</span>
</div>

@if(! $isSuccessful)
<div class="mb-1">
<span class="px-1 bg-yellow text-white uppercase">Warn</span>
<span class="ml-1">
Run <span class="text-yellow">./vendor/bin/pint --dirty --test -v</span> to see coding standard detail issues.
</span>
</div>
<div class="mb-1">
<span class="px-1 bg-yellow text-white uppercase">Warn</span>
<span class="ml-1">
Run <span class="text-yellow">./vendor/bin/pint --dirty</span> to fix coding standard issues.
</span>
</div>
@else
<div class="mb-1">
<span class="px-1 bg-green text-white uppercase">Success</span>
<span class="ml-1">Your code is perfect, no syntax error found!</span>
</div>
@endif
</div>
20 changes: 11 additions & 9 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

namespace Botble\GitCommitChecker\Commands;

use Illuminate\Console\Application;
use Illuminate\Console\Command;
use Illuminate\Console\ConfirmableTrait;
use Symfony\Component\Console\Attribute\AsCommand;
@@ -35,14 +36,14 @@ public function handle(): int
$pintConfigFilePath = $this->laravel->basePath('pint.json');

if ($this->laravel['files']->exists($pintConfigFilePath)) {
if ($this->components->confirm('A pint.json exists. Do you want to overwrite this file?')) {
if ($this->components->confirm('A <comment>pint.json</comment> exists. Do you want to overwrite this file?')) {
$this->generatePintConfiguration($pintConfigFilePath);
}

return self::SUCCESS;
}

if ($this->components->confirm('A pint.json does not exists. Do you want to create this file?')) {
if ($this->components->confirm('A <comment>pint.json</comment> does not exists. Do you want to create this file?')) {
$this->generatePintConfiguration($pintConfigFilePath);
}

@@ -66,10 +67,11 @@ protected function install(string $hook, string $class): bool
$script = $this->generateHookScript($command->getName());

$path = $this->laravel->basePath('.git/hooks/' . $hook);
$relativePath = ltrim(str_replace($this->laravel->basePath(), '', $path), DIRECTORY_SEPARATOR);

if (
$this->laravel['files']->exists($path) &&
! $this->confirmToProceed($path . ' already exists, do you want to overwrite it?', true)
! $this->confirmToProceed($relativePath . ' already exists, do you want to overwrite it?', true)
) {
return false;
}
@@ -79,9 +81,7 @@ protected function install(string $hook, string $class): bool

protected function generateHookScript(string $signature): string
{
$artisan = addslashes($this->laravel->basePath('artisan'));

return "#!/bin/sh\n\nphp $artisan $signature\n";
return sprintf("#!/bin/sh\n\n%s\n", Application::formatCommandString($signature));
}

protected function generatePintConfiguration(string $path): void
@@ -100,17 +100,19 @@ protected function generatePintConfiguration(string $path): void
if (! $this->laravel['files']->put(
$path,
json_encode(
$standard !== 'recommended'
$preset !== 'recommended'
? ['preset' => $preset]
: $this->laravel['config']->get('git-commit-checker.pint.recommended_preset'),
JSON_PRETTY_PRINT
)
) . PHP_EOL
)) {
$this->components->error('Unable to write ' . $path);
abort(1);
}

$this->components->info("Created [$path] using $presets[$preset] preset successfully");
$this->components->info(
"Created <comment>$path</comment> using <comment>$presets[$preset]</comment> preset successfully"
);
}

protected function writeHookScript(string $path, string $script): bool
22 changes: 16 additions & 6 deletions src/Commands/PreCommitHookCommand.php
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Process\Process;

use function Termwind\render;

#[AsCommand('git-commit-checker:pre-commit-hook', 'Git hook before commit')]
class PreCommitHookCommand extends Command
{
@@ -31,21 +33,29 @@ public function handle(): int
$command = [
$this->laravel->basePath('vendor/bin/pint'),
'--test',
'--format=json',
'-v',
];

$command = array_merge($command, $uncommittedFiles);

$process = $this->getProcess($command);

$process->setTty(true);

$process->run();

if (! $process->isSuccessful()) {
$this->components->warn('Run <comment>./vendor/bin/pint --dirty --test -v</comment> to see coding standard detail issues');
$this->components->warn('Run <comment>./vendor/bin/pint --dirty</comment> to fix coding standard issues');
if ($process->getOutput()) {
$result = json_decode($process->getOutput(), true);

render(
view('git-commit-checker::summary', [
'result' => $result,
'isSuccessful' => $process->isSuccessful(),
])
);

return self::FAILURE;
if (! $process->isSuccessful()) {
return self::FAILURE;
}
}

return self::SUCCESS;
2 changes: 2 additions & 0 deletions src/Providers/GitCommitCheckerServiceProvider.php
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@ public function boot()
{
$this->app->register(CommandServiceProvider::class);

$this->loadViewsFrom(__DIR__ . '/../../resources/views', 'git-commit-checker');

if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../../config/git-commit-checker.php' => config_path('git-commit-checker.php'),