{"action":"created","issue":{"url":"https://api.github.com/repos/squizlabs/PHP_CodeSniffer/issues/456","labels_url":"https://api.github.com/repos/squizlabs/PHP_CodeSniffer/issues/456/labels{/name}","comments_url":"https://api.github.com/repos/squizlabs/PHP_CodeSniffer/issues/456/comments","events_url":"https://api.github.com/repos/squizlabs/PHP_CodeSniffer/issues/456/events","html_url":"https://github.com/squizlabs/PHP_CodeSniffer/issues/456","id":55363892,"number":456,"title":"Add a new section about Git Hooks to the wiki","user":{"login":"Konafets","id":363363,"avatar_url":"https://avatars.githubusercontent.com/u/363363?v=3","gravatar_id":"","url":"https://api.github.com/users/Konafets","html_url":"https://github.com/Konafets","followers_url":"https://api.github.com/users/Konafets/followers","following_url":"https://api.github.com/users/Konafets/following{/other_user}","gists_url":"https://api.github.com/users/Konafets/gists{/gist_id}","starred_url":"https://api.github.com/users/Konafets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Konafets/subscriptions","organizations_url":"https://api.github.com/users/Konafets/orgs","repos_url":"https://api.github.com/users/Konafets/repos","events_url":"https://api.github.com/users/Konafets/events{/privacy}","received_events_url":"https://api.github.com/users/Konafets/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-24T08:59:16Z","updated_at":"2015-01-24T17:28:37Z","closed_at":null,"body":"# First draft:\r\n\r\n# Introduction of Git-Hooks\r\n   (can be mainly taken from the current SVN-Hooks text)\r\n\r\n# Create a Hook\r\n\r\nHooks in GIT are located inside /path/to/project/.git/hooks/. GIT is shipped with some examples which can be find in this folder. The hook itself is just a shell script, which get executed when the hooks is called.\r\n\r\nWe will create a pre-push hook, which calls the PHP_CodeSniffer before pushing to remote. \r\n\r\nCreate a file ```pre-push``` inside ```.git/hooks/```\r\n\r\n```\r\n$ cd /path/to/project/\r\n$ touch .git/hooks/pre-push\r\n$ chmod +x .git/hooks/pre-push\r\n```\r\nand insert the following content:\r\n\r\n```\r\n#! /bin/zsh -l\r\n\r\necho \"Executing pre-push hook\"\r\n\r\ngit stash -q --keep-index\r\nphpcs\r\nRESULT=$?\r\ngit stash pop -q\r\n\r\nif [[ $RESULT != 0 ]]; then\r\n    echo \"There are failing results. Aborting.\" 1>&2\r\n    exit 1\r\nfi\r\n```\r\n\r\nThe script stashes files which are not commited yet and reapply the stash after the actual check was made. **You are not loosing any data by this script.**\r\n\r\nThe hooks will executed when you push to remote. You can bypass the hook with adding the option ```--no-verify``` to the push command.\r\n"},"comment":{"url":"https://api.github.com/repos/squizlabs/PHP_CodeSniffer/issues/comments/71328241","html_url":"https://github.com/squizlabs/PHP_CodeSniffer/issues/456#issuecomment-71328241","issue_url":"https://api.github.com/repos/squizlabs/PHP_CodeSniffer/issues/456","id":71328241,"user":{"login":"jian-wu","id":1561024,"avatar_url":"https://avatars.githubusercontent.com/u/1561024?v=3","gravatar_id":"","url":"https://api.github.com/users/jian-wu","html_url":"https://github.com/jian-wu","followers_url":"https://api.github.com/users/jian-wu/followers","following_url":"https://api.github.com/users/jian-wu/following{/other_user}","gists_url":"https://api.github.com/users/jian-wu/gists{/gist_id}","starred_url":"https://api.github.com/users/jian-wu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jian-wu/subscriptions","organizations_url":"https://api.github.com/users/jian-wu/orgs","repos_url":"https://api.github.com/users/jian-wu/repos","events_url":"https://api.github.com/users/jian-wu/events{/privacy}","received_events_url":"https://api.github.com/users/jian-wu/received_events","type":"User","site_admin":false},"created_at":"2015-01-24T17:28:37Z","updated_at":"2015-01-24T17:28:37Z","body":"Great writeup.  However, there's a few grammar/spelling issues.  How do I make inline comments?  Thanks."}}