Skip to content

Instantly share code, notes, and snippets.

@martinbean
Last active December 19, 2023 22:14
Show Gist options
  • Save martinbean/0eb43b1ba647bca18064 to your computer and use it in GitHub Desktop.
Save martinbean/0eb43b1ba647bca18064 to your computer and use it in GitHub Desktop.

Revisions

  1. martinbean revised this gist Feb 8, 2016. No changes.
  2. martinbean revised this gist Feb 3, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pre-commit
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ foreach ($files as $file) {
    $lines = file($file);

    foreach ($lines as $line => $content) {
    if (preg_match('/\sdd\(/', $content)) {
    if (preg_match('/\bdd\(/', $content)) {
    printf("\033[0;31mdd() found on line %d in %s\033[0m\n", $line + 1, $file);
    $exitCode = 1;
    }
  3. martinbean revised this gist Jan 28, 2016. 1 changed file with 1 addition and 6 deletions.
    7 changes: 1 addition & 6 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,12 @@
    #!/usr/bin/php
    <?php

    $files = shell_exec('git diff-index --name-only --cached --diff-filter=ACMR HEAD');
    $files = shell_exec('git diff-index --name-only --cached --diff-filter=ACMR HEAD | grep "\.php$"');
    $files = explode("\n", trim($files));

    $exitCode = 0;

    foreach ($files as $file) {
    // Only check files with .php extension
    if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) != 'php') {
    continue;
    }

    if (empty($file)) {
    continue;
    }
  4. martinbean revised this gist Jan 28, 2016. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,11 @@ $files = explode("\n", trim($files));
    $exitCode = 0;

    foreach ($files as $file) {
    // Only check files with .php extension
    if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) != 'php') {
    continue;
    }

    if (empty($file)) {
    continue;
    }
  5. martinbean revised this gist Jan 28, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion pre-commit
    Original file line number Diff line number Diff line change
    @@ -7,10 +7,14 @@ $files = explode("\n", trim($files));
    $exitCode = 0;

    foreach ($files as $file) {
    if (empty($file)) {
    continue;
    }

    $lines = file($file);

    foreach ($lines as $line => $content) {
    if (preg_match('/dd\(/', $content)) {
    if (preg_match('/\sdd\(/', $content)) {
    printf("\033[0;31mdd() found on line %d in %s\033[0m\n", $line + 1, $file);
    $exitCode = 1;
    }
  6. martinbean created this gist Jan 27, 2016.
    20 changes: 20 additions & 0 deletions pre-commit
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/usr/bin/php
    <?php

    $files = shell_exec('git diff-index --name-only --cached --diff-filter=ACMR HEAD');
    $files = explode("\n", trim($files));

    $exitCode = 0;

    foreach ($files as $file) {
    $lines = file($file);

    foreach ($lines as $line => $content) {
    if (preg_match('/dd\(/', $content)) {
    printf("\033[0;31mdd() found on line %d in %s\033[0m\n", $line + 1, $file);
    $exitCode = 1;
    }
    }
    }

    exit($exitCode);