GithubHelp home page GithubHelp logo

alexander-po / diff-sniffer-pre-commit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tuslo/diff-sniffer-pre-commit

0.0 2.0 0.0 259 KB

Git pre-commit hook for Diff Sniffer

PHP 99.29% Batchfile 0.71%

diff-sniffer-pre-commit's Introduction

Diff Sniffer Pre-Commit Hook

This tool allows you using PHP_CodeSniffer as a pre-commit hook. The main difference from existing solutions that this one validates only changed lines of code but not the whole source tree.

Installation

Diff Sniffer is already built as PHAR-package with a few predefined configurations. All you need is download it and install as a pre-commit hook.

$ wget https://github.com/morozov/diff-sniffer-pre-commit/releases/download/2.3.0/pre-commit.phar
$ chmod +x pre-commit.phar
$ mv pre-commit.phar /path/to/repo/.git/hooks/pre-commit

You can also install and configure Diff Sniffer manually.

$ git clone [email protected]:morozov/diff-sniffer-pre-commit.git
$ composer update
$ ln -s /path/to/diff-sniffer-pre-commit/bin/pre-commit /path/to/repo/.git/hooks/

Configuration

The coding standard used by default may be defined in config.php (the release package is pre-configured with PSR2). Similarly to PHP_CodeSniffer, both embedded and custom standards may be used.

<?php

return array(
    '--standard=Zend',
);

or

<?php

return array(
    '--standard=/path/to/custom/standard',
);

If you want to reuse the same installation of Diff Sniffer with different standards, you can pass --standard as command line option. You should use shell script wrapper as pre-commit hook instead of symlink then.

#!/bin/bash

/path/to/diff-sniffer-pre-commit/bin/pre-commit --standard=PEAR

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.