{"action":"created","comment":{"url":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/comments/51350900","id":51350900,"diff_hunk":"@@ -0,0 +1,31 @@\n+#!/bin/bash\n+\n+protected_branch='master'\n+\n+policy='[Policy] Never force push or delete the '$protected_branch' branch! (Prevented with pre-push hook.)'\n+\n+current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\\(.*\\),\\1,')\n+\n+parent_pid=$(ps -oppid= -p $PPID)\n+push_command=$(ps -ocommand= -p $parent_pid)\n+\n+is_destructive='force|delete|\\-f'\n+\n+will_remove_protected_branch=':'$protected_branch\n+\n+do_exit(){\n+  echo $policy\n+  exit 1\n+}\n+\n+if [[ $push_command =~ $is_destructive ]] && [[ $push_command =~ $protected_branch ]]; then","path":"examples/pre-push/prevent-force-push-to-master","position":21,"original_position":21,"commit_id":"90c9cd1308ef294346e03c1f30f8a9bd3d9fcbc4","original_commit_id":"90c9cd1308ef294346e03c1f30f8a9bd3d9fcbc4","user":{"login":"tarmolov","id":366419,"avatar_url":"https://avatars.githubusercontent.com/u/366419?v=3","gravatar_id":"","url":"https://api.github.com/users/tarmolov","html_url":"https://github.com/tarmolov","followers_url":"https://api.github.com/users/tarmolov/followers","following_url":"https://api.github.com/users/tarmolov/following{/other_user}","gists_url":"https://api.github.com/users/tarmolov/gists{/gist_id}","starred_url":"https://api.github.com/users/tarmolov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarmolov/subscriptions","organizations_url":"https://api.github.com/users/tarmolov/orgs","repos_url":"https://api.github.com/users/tarmolov/repos","events_url":"https://api.github.com/users/tarmolov/events{/privacy}","received_events_url":"https://api.github.com/users/tarmolov/received_events","type":"User","site_admin":false},"body":"It seems that two conditions can be merged into a single one and then `do_exit` function can be inlined.","created_at":"2016-01-30T21:05:17Z","updated_at":"2016-01-30T21:05:17Z","html_url":"https://github.com/tarmolov/git-hooks-js/pull/13#discussion_r51350900","pull_request_url":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/comments/51350900"},"html":{"href":"https://github.com/tarmolov/git-hooks-js/pull/13#discussion_r51350900"},"pull_request":{"href":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/13","id":57748875,"html_url":"https://github.com/tarmolov/git-hooks-js/pull/13","diff_url":"https://github.com/tarmolov/git-hooks-js/pull/13.diff","patch_url":"https://github.com/tarmolov/git-hooks-js/pull/13.patch","issue_url":"https://api.github.com/repos/tarmolov/git-hooks-js/issues/13","number":13,"state":"open","locked":false,"title":"Add pre-push hook example","user":{"login":"nik-kor","id":266570,"avatar_url":"https://avatars.githubusercontent.com/u/266570?v=3","gravatar_id":"","url":"https://api.github.com/users/nik-kor","html_url":"https://github.com/nik-kor","followers_url":"https://api.github.com/users/nik-kor/followers","following_url":"https://api.github.com/users/nik-kor/following{/other_user}","gists_url":"https://api.github.com/users/nik-kor/gists{/gist_id}","starred_url":"https://api.github.com/users/nik-kor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nik-kor/subscriptions","organizations_url":"https://api.github.com/users/nik-kor/orgs","repos_url":"https://api.github.com/users/nik-kor/repos","events_url":"https://api.github.com/users/nik-kor/events{/privacy}","received_events_url":"https://api.github.com/users/nik-kor/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-30T19:56:23Z","updated_at":"2016-01-30T21:05:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5c190b57ffae1d81fefd1259b09e7f7d6da37f0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/13/commits","review_comments_url":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/13/comments","review_comment_url":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tarmolov/git-hooks-js/issues/13/comments","statuses_url":"https://api.github.com/repos/tarmolov/git-hooks-js/statuses/90c9cd1308ef294346e03c1f30f8a9bd3d9fcbc4","head":{"label":"nik-kor:master","ref":"master","sha":"90c9cd1308ef294346e03c1f30f8a9bd3d9fcbc4","user":{"login":"nik-kor","id":266570,"avatar_url":"https://avatars.githubusercontent.com/u/266570?v=3","gravatar_id":"","url":"https://api.github.com/users/nik-kor","html_url":"https://github.com/nik-kor","followers_url":"https://api.github.com/users/nik-kor/followers","following_url":"https://api.github.com/users/nik-kor/following{/other_user}","gists_url":"https://api.github.com/users/nik-kor/gists{/gist_id}","starred_url":"https://api.github.com/users/nik-kor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nik-kor/subscriptions","organizations_url":"https://api.github.com/users/nik-kor/orgs","repos_url":"https://api.github.com/users/nik-kor/repos","events_url":"https://api.github.com/users/nik-kor/events{/privacy}","received_events_url":"https://api.github.com/users/nik-kor/received_events","type":"User","site_admin":false},"repo":{"id":50519498,"name":"git-hooks-js","full_name":"nik-kor/git-hooks-js","owner":{"login":"nik-kor","id":266570,"avatar_url":"https://avatars.githubusercontent.com/u/266570?v=3","gravatar_id":"","url":"https://api.github.com/users/nik-kor","html_url":"https://github.com/nik-kor","followers_url":"https://api.github.com/users/nik-kor/followers","following_url":"https://api.github.com/users/nik-kor/following{/other_user}","gists_url":"https://api.github.com/users/nik-kor/gists{/gist_id}","starred_url":"https://api.github.com/users/nik-kor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nik-kor/subscriptions","organizations_url":"https://api.github.com/users/nik-kor/orgs","repos_url":"https://api.github.com/users/nik-kor/repos","events_url":"https://api.github.com/users/nik-kor/events{/privacy}","received_events_url":"https://api.github.com/users/nik-kor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nik-kor/git-hooks-js","description":"A tool to manage and run project git hooks","fork":true,"url":"https://api.github.com/repos/nik-kor/git-hooks-js","forks_url":"https://api.github.com/repos/nik-kor/git-hooks-js/forks","keys_url":"https://api.github.com/repos/nik-kor/git-hooks-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nik-kor/git-hooks-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nik-kor/git-hooks-js/teams","hooks_url":"https://api.github.com/repos/nik-kor/git-hooks-js/hooks","issue_events_url":"https://api.github.com/repos/nik-kor/git-hooks-js/issues/events{/number}","events_url":"https://api.github.com/repos/nik-kor/git-hooks-js/events","assignees_url":"https://api.github.com/repos/nik-kor/git-hooks-js/assignees{/user}","branches_url":"https://api.github.com/repos/nik-kor/git-hooks-js/branches{/branch}","tags_url":"https://api.github.com/repos/nik-kor/git-hooks-js/tags","blobs_url":"https://api.github.com/repos/nik-kor/git-hooks-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nik-kor/git-hooks-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nik-kor/git-hooks-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/nik-kor/git-hooks-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nik-kor/git-hooks-js/statuses/{sha}","languages_url":"https://api.github.com/repos/nik-kor/git-hooks-js/languages","stargazers_url":"https://api.github.com/repos/nik-kor/git-hooks-js/stargazers","contributors_url":"https://api.github.com/repos/nik-kor/git-hooks-js/contributors","subscribers_url":"https://api.github.com/repos/nik-kor/git-hooks-js/subscribers","subscription_url":"https://api.github.com/repos/nik-kor/git-hooks-js/subscription","commits_url":"https://api.github.com/repos/nik-kor/git-hooks-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/nik-kor/git-hooks-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/nik-kor/git-hooks-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/nik-kor/git-hooks-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/nik-kor/git-hooks-js/contents/{+path}","compare_url":"https://api.github.com/repos/nik-kor/git-hooks-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nik-kor/git-hooks-js/merges","archive_url":"https://api.github.com/repos/nik-kor/git-hooks-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nik-kor/git-hooks-js/downloads","issues_url":"https://api.github.com/repos/nik-kor/git-hooks-js/issues{/number}","pulls_url":"https://api.github.com/repos/nik-kor/git-hooks-js/pulls{/number}","milestones_url":"https://api.github.com/repos/nik-kor/git-hooks-js/milestones{/number}","notifications_url":"https://api.github.com/repos/nik-kor/git-hooks-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nik-kor/git-hooks-js/labels{/name}","releases_url":"https://api.github.com/repos/nik-kor/git-hooks-js/releases{/id}","deployments_url":"https://api.github.com/repos/nik-kor/git-hooks-js/deployments","created_at":"2016-01-27T16:08:09Z","updated_at":"2016-01-27T16:08:10Z","pushed_at":"2016-01-30T19:55:44Z","git_url":"git://github.com/nik-kor/git-hooks-js.git","ssh_url":"git@github.com:nik-kor/git-hooks-js.git","clone_url":"https://github.com/nik-kor/git-hooks-js.git","svn_url":"https://github.com/nik-kor/git-hooks-js","homepage":"","size":41,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tarmolov:master","ref":"master","sha":"5d21c5dea9bdb3cc172bba26c816f54034026460","user":{"login":"tarmolov","id":366419,"avatar_url":"https://avatars.githubusercontent.com/u/366419?v=3","gravatar_id":"","url":"https://api.github.com/users/tarmolov","html_url":"https://github.com/tarmolov","followers_url":"https://api.github.com/users/tarmolov/followers","following_url":"https://api.github.com/users/tarmolov/following{/other_user}","gists_url":"https://api.github.com/users/tarmolov/gists{/gist_id}","starred_url":"https://api.github.com/users/tarmolov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarmolov/subscriptions","organizations_url":"https://api.github.com/users/tarmolov/orgs","repos_url":"https://api.github.com/users/tarmolov/repos","events_url":"https://api.github.com/users/tarmolov/events{/privacy}","received_events_url":"https://api.github.com/users/tarmolov/received_events","type":"User","site_admin":false},"repo":{"id":37948129,"name":"git-hooks-js","full_name":"tarmolov/git-hooks-js","owner":{"login":"tarmolov","id":366419,"avatar_url":"https://avatars.githubusercontent.com/u/366419?v=3","gravatar_id":"","url":"https://api.github.com/users/tarmolov","html_url":"https://github.com/tarmolov","followers_url":"https://api.github.com/users/tarmolov/followers","following_url":"https://api.github.com/users/tarmolov/following{/other_user}","gists_url":"https://api.github.com/users/tarmolov/gists{/gist_id}","starred_url":"https://api.github.com/users/tarmolov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarmolov/subscriptions","organizations_url":"https://api.github.com/users/tarmolov/orgs","repos_url":"https://api.github.com/users/tarmolov/repos","events_url":"https://api.github.com/users/tarmolov/events{/privacy}","received_events_url":"https://api.github.com/users/tarmolov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tarmolov/git-hooks-js","description":"A tool to manage and run project git hooks","fork":false,"url":"https://api.github.com/repos/tarmolov/git-hooks-js","forks_url":"https://api.github.com/repos/tarmolov/git-hooks-js/forks","keys_url":"https://api.github.com/repos/tarmolov/git-hooks-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tarmolov/git-hooks-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tarmolov/git-hooks-js/teams","hooks_url":"https://api.github.com/repos/tarmolov/git-hooks-js/hooks","issue_events_url":"https://api.github.com/repos/tarmolov/git-hooks-js/issues/events{/number}","events_url":"https://api.github.com/repos/tarmolov/git-hooks-js/events","assignees_url":"https://api.github.com/repos/tarmolov/git-hooks-js/assignees{/user}","branches_url":"https://api.github.com/repos/tarmolov/git-hooks-js/branches{/branch}","tags_url":"https://api.github.com/repos/tarmolov/git-hooks-js/tags","blobs_url":"https://api.github.com/repos/tarmolov/git-hooks-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tarmolov/git-hooks-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tarmolov/git-hooks-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/tarmolov/git-hooks-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tarmolov/git-hooks-js/statuses/{sha}","languages_url":"https://api.github.com/repos/tarmolov/git-hooks-js/languages","stargazers_url":"https://api.github.com/repos/tarmolov/git-hooks-js/stargazers","contributors_url":"https://api.github.com/repos/tarmolov/git-hooks-js/contributors","subscribers_url":"https://api.github.com/repos/tarmolov/git-hooks-js/subscribers","subscription_url":"https://api.github.com/repos/tarmolov/git-hooks-js/subscription","commits_url":"https://api.github.com/repos/tarmolov/git-hooks-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/tarmolov/git-hooks-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/tarmolov/git-hooks-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/tarmolov/git-hooks-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/tarmolov/git-hooks-js/contents/{+path}","compare_url":"https://api.github.com/repos/tarmolov/git-hooks-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tarmolov/git-hooks-js/merges","archive_url":"https://api.github.com/repos/tarmolov/git-hooks-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tarmolov/git-hooks-js/downloads","issues_url":"https://api.github.com/repos/tarmolov/git-hooks-js/issues{/number}","pulls_url":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls{/number}","milestones_url":"https://api.github.com/repos/tarmolov/git-hooks-js/milestones{/number}","notifications_url":"https://api.github.com/repos/tarmolov/git-hooks-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tarmolov/git-hooks-js/labels{/name}","releases_url":"https://api.github.com/repos/tarmolov/git-hooks-js/releases{/id}","deployments_url":"https://api.github.com/repos/tarmolov/git-hooks-js/deployments","created_at":"2015-06-23T22:17:33Z","updated_at":"2016-01-04T18:50:21Z","pushed_at":"2016-01-30T19:56:23Z","git_url":"git://github.com/tarmolov/git-hooks-js.git","ssh_url":"git@github.com:tarmolov/git-hooks-js.git","clone_url":"https://github.com/tarmolov/git-hooks-js.git","svn_url":"https://github.com/tarmolov/git-hooks-js","homepage":"","size":43,"stargazers_count":63,"watchers_count":63,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":6,"forks":6,"open_issues":6,"watchers":63,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/13"},"html":{"href":"https://github.com/tarmolov/git-hooks-js/pull/13"},"issue":{"href":"https://api.github.com/repos/tarmolov/git-hooks-js/issues/13"},"comments":{"href":"https://api.github.com/repos/tarmolov/git-hooks-js/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tarmolov/git-hooks-js/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/tarmolov/git-hooks-js/statuses/90c9cd1308ef294346e03c1f30f8a9bd3d9fcbc4"}}}}