{"action":"created","comment":{"url":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/comments/33343541","id":33343541,"diff_hunk":"@@ -0,0 +1,87 @@\n+require 'support/publicize_methods.rb'\n+require 'spec_helper'\n+require 'gitlab_custom_hook'\n+\n+describe GitlabCustomHook do\n+  let(:repository_path) { '/home/git/repositories' }\n+  let(:repo_name)   { 'dzaporozhets/gitlab-ci' }\n+  let(:repo_path)  { File.join(repository_path, repo_name) + '.git' }\n+  let(:gitlab_custom_hooks) { GitlabCustomHook.new }\n+  let(:local_pre_receive) { File.join(repo_path, 'custom_hook', 'pre-receive') }\n+  let(:local_post_receive) { File.join(repo_path, 'custom_hook', 'post-receive') }\n+  let(:global_pre_receive) { File.join(ROOT_PATH, 'custom_hook', 'pre-receive') }\n+  let(:global_post_receive) { File.join(ROOT_PATH, 'custom_hook', 'post-receive') }\n+\n+  describe 'select hook file' do\n+    context 'with nil arguments' do\n+      it 'returns nil' do\n+        GitlabCustomHook.publicize_methods do\n+          expect(gitlab_custom_hooks.hook_file(nil, repo_path)).to eq(nil)\n+          expect(gitlab_custom_hooks.hook_file('post-receive', nil)).to eq(nil)\n+          expect(gitlab_custom_hooks.hook_file(nil, nil)).to eq(nil)\n+        end\n+      end\n+    end\n+\n+    context 'when the local hook path exists' do\n+      before do\n+        File.stub(:exist?).with(local_post_receive).and_return(true)\n+        File.stub(:exist?).with(local_pre_receive).and_return(true)\n+      end\n+      context 'when the global hook path exists' do\n+        before do\n+          File.stub(:exist?).with(global_post_receive).and_return(true)\n+          File.stub(:exist?).with(global_pre_receive).and_return(true)\n+        end\n+        it 'returns the local hook file' do\n+          GitlabCustomHook.publicize_methods do\n+            expect(gitlab_custom_hooks.hook_file('pre-receive', repo_path)).to eq(local_pre_receive)\n+            expect(gitlab_custom_hooks.hook_file('post-receive', repo_path)).to eq(local_post_receive)\n+          end\n+        end\n+      end\n+      context 'when the global hook path does not exist' do\n+        before do\n+          File.stub(:exist?).with(global_post_receive).and_return(false)\n+          File.stub(:exist?).with(global_pre_receive).and_return(false)\n+        end\n+        it 'returns the local hook file' do\n+          GitlabCustomHook.publicize_methods do\n+            expect(gitlab_custom_hooks.hook_file('pre-receive', repo_path)).to eq(local_pre_receive)\n+            expect(gitlab_custom_hooks.hook_file('post-receive', repo_path)).to eq(local_post_receive)\n+          end\n+        end\n+      end\n+    end\n+    context 'when the local hook path does not exists' do\n+      before do\n+        File.stub(:exist?).with(local_post_receive).and_return(false)\n+        File.stub(:exist?).with(local_pre_receive).and_return(false)\n+      end\n+      context 'when the global hook path exists' do\n+        before do\n+          File.stub(:exist?).with(global_post_receive).and_return(true)\n+          File.stub(:exist?).with(global_pre_receive).and_return(true)\n+        end\n+        it 'returns the local hook file' do\n+          GitlabCustomHook.publicize_methods do\n+            expect(gitlab_custom_hooks.hook_file('pre-receive', repo_path)).to eq(global_pre_receive)","path":"spec/gitlab_custom_hooks.rb","position":68,"original_position":68,"commit_id":"96490ce52ac7394e91215616c776ca35a64a54f5","original_commit_id":"96490ce52ac7394e91215616c776ca35a64a54f5","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long. [101/80]","created_at":"2015-06-26T10:08:35Z","updated_at":"2015-06-26T10:08:35Z","html_url":"https://github.com/gitlabhq/gitlab-shell/pull/229#discussion_r33343541","pull_request_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/229","_links":{"self":{"href":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/comments/33343541"},"html":{"href":"https://github.com/gitlabhq/gitlab-shell/pull/229#discussion_r33343541"},"pull_request":{"href":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/229"}}},"pull_request":{"url":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/229","id":38634086,"html_url":"https://github.com/gitlabhq/gitlab-shell/pull/229","diff_url":"https://github.com/gitlabhq/gitlab-shell/pull/229.diff","patch_url":"https://github.com/gitlabhq/gitlab-shell/pull/229.patch","issue_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/issues/229","number":229,"state":"open","locked":false,"title":"Hooks/custom/global","user":{"login":"tjamet","id":6061440,"avatar_url":"https://avatars.githubusercontent.com/u/6061440?v=3","gravatar_id":"","url":"https://api.github.com/users/tjamet","html_url":"https://github.com/tjamet","followers_url":"https://api.github.com/users/tjamet/followers","following_url":"https://api.github.com/users/tjamet/following{/other_user}","gists_url":"https://api.github.com/users/tjamet/gists{/gist_id}","starred_url":"https://api.github.com/users/tjamet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjamet/subscriptions","organizations_url":"https://api.github.com/users/tjamet/orgs","repos_url":"https://api.github.com/users/tjamet/repos","events_url":"https://api.github.com/users/tjamet/events{/privacy}","received_events_url":"https://api.github.com/users/tjamet/received_events","type":"User","site_admin":false},"body":"The goal of this PR is to simplify the creation of new repositories in case hooks should be shared between all projects.\r\nCustom hooks will first be looked in the repository's custom hooks then in the global custom_hooks if not found in the repository.","created_at":"2015-06-26T09:58:23Z","updated_at":"2015-06-26T10:08:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d22f28cfdc3d7ab71d917955045d13f172b3fd74","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/229/commits","review_comments_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/229/comments","review_comment_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/issues/229/comments","statuses_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/statuses/96490ce52ac7394e91215616c776ca35a64a54f5","head":{"label":"tjamet:hooks/custom/global","ref":"hooks/custom/global","sha":"96490ce52ac7394e91215616c776ca35a64a54f5","user":{"login":"tjamet","id":6061440,"avatar_url":"https://avatars.githubusercontent.com/u/6061440?v=3","gravatar_id":"","url":"https://api.github.com/users/tjamet","html_url":"https://github.com/tjamet","followers_url":"https://api.github.com/users/tjamet/followers","following_url":"https://api.github.com/users/tjamet/following{/other_user}","gists_url":"https://api.github.com/users/tjamet/gists{/gist_id}","starred_url":"https://api.github.com/users/tjamet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjamet/subscriptions","organizations_url":"https://api.github.com/users/tjamet/orgs","repos_url":"https://api.github.com/users/tjamet/repos","events_url":"https://api.github.com/users/tjamet/events{/privacy}","received_events_url":"https://api.github.com/users/tjamet/received_events","type":"User","site_admin":false},"repo":{"id":38100878,"name":"gitlab-shell","full_name":"tjamet/gitlab-shell","owner":{"login":"tjamet","id":6061440,"avatar_url":"https://avatars.githubusercontent.com/u/6061440?v=3","gravatar_id":"","url":"https://api.github.com/users/tjamet","html_url":"https://github.com/tjamet","followers_url":"https://api.github.com/users/tjamet/followers","following_url":"https://api.github.com/users/tjamet/following{/other_user}","gists_url":"https://api.github.com/users/tjamet/gists{/gist_id}","starred_url":"https://api.github.com/users/tjamet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjamet/subscriptions","organizations_url":"https://api.github.com/users/tjamet/orgs","repos_url":"https://api.github.com/users/tjamet/repos","events_url":"https://api.github.com/users/tjamet/events{/privacy}","received_events_url":"https://api.github.com/users/tjamet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tjamet/gitlab-shell","description":"Replacement for gitolite","fork":true,"url":"https://api.github.com/repos/tjamet/gitlab-shell","forks_url":"https://api.github.com/repos/tjamet/gitlab-shell/forks","keys_url":"https://api.github.com/repos/tjamet/gitlab-shell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tjamet/gitlab-shell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tjamet/gitlab-shell/teams","hooks_url":"https://api.github.com/repos/tjamet/gitlab-shell/hooks","issue_events_url":"https://api.github.com/repos/tjamet/gitlab-shell/issues/events{/number}","events_url":"https://api.github.com/repos/tjamet/gitlab-shell/events","assignees_url":"https://api.github.com/repos/tjamet/gitlab-shell/assignees{/user}","branches_url":"https://api.github.com/repos/tjamet/gitlab-shell/branches{/branch}","tags_url":"https://api.github.com/repos/tjamet/gitlab-shell/tags","blobs_url":"https://api.github.com/repos/tjamet/gitlab-shell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tjamet/gitlab-shell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tjamet/gitlab-shell/git/refs{/sha}","trees_url":"https://api.github.com/repos/tjamet/gitlab-shell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tjamet/gitlab-shell/statuses/{sha}","languages_url":"https://api.github.com/repos/tjamet/gitlab-shell/languages","stargazers_url":"https://api.github.com/repos/tjamet/gitlab-shell/stargazers","contributors_url":"https://api.github.com/repos/tjamet/gitlab-shell/contributors","subscribers_url":"https://api.github.com/repos/tjamet/gitlab-shell/subscribers","subscription_url":"https://api.github.com/repos/tjamet/gitlab-shell/subscription","commits_url":"https://api.github.com/repos/tjamet/gitlab-shell/commits{/sha}","git_commits_url":"https://api.github.com/repos/tjamet/gitlab-shell/git/commits{/sha}","comments_url":"https://api.github.com/repos/tjamet/gitlab-shell/comments{/number}","issue_comment_url":"https://api.github.com/repos/tjamet/gitlab-shell/issues/comments{/number}","contents_url":"https://api.github.com/repos/tjamet/gitlab-shell/contents/{+path}","compare_url":"https://api.github.com/repos/tjamet/gitlab-shell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tjamet/gitlab-shell/merges","archive_url":"https://api.github.com/repos/tjamet/gitlab-shell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tjamet/gitlab-shell/downloads","issues_url":"https://api.github.com/repos/tjamet/gitlab-shell/issues{/number}","pulls_url":"https://api.github.com/repos/tjamet/gitlab-shell/pulls{/number}","milestones_url":"https://api.github.com/repos/tjamet/gitlab-shell/milestones{/number}","notifications_url":"https://api.github.com/repos/tjamet/gitlab-shell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tjamet/gitlab-shell/labels{/name}","releases_url":"https://api.github.com/repos/tjamet/gitlab-shell/releases{/id}","created_at":"2015-06-26T08:49:09Z","updated_at":"2015-06-26T08:49:10Z","pushed_at":"2015-06-26T10:08:28Z","git_url":"git://github.com/tjamet/gitlab-shell.git","ssh_url":"git@github.com:tjamet/gitlab-shell.git","clone_url":"https://github.com/tjamet/gitlab-shell.git","svn_url":"https://github.com/tjamet/gitlab-shell","homepage":null,"size":500,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"gitlabhq:master","ref":"master","sha":"4d30c0c5d3d0f23a221ee507b6bd110a539b8570","user":{"login":"gitlabhq","id":1086321,"avatar_url":"https://avatars.githubusercontent.com/u/1086321?v=3","gravatar_id":"","url":"https://api.github.com/users/gitlabhq","html_url":"https://github.com/gitlabhq","followers_url":"https://api.github.com/users/gitlabhq/followers","following_url":"https://api.github.com/users/gitlabhq/following{/other_user}","gists_url":"https://api.github.com/users/gitlabhq/gists{/gist_id}","starred_url":"https://api.github.com/users/gitlabhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitlabhq/subscriptions","organizations_url":"https://api.github.com/users/gitlabhq/orgs","repos_url":"https://api.github.com/users/gitlabhq/repos","events_url":"https://api.github.com/users/gitlabhq/events{/privacy}","received_events_url":"https://api.github.com/users/gitlabhq/received_events","type":"Organization","site_admin":false},"repo":{"id":8003417,"name":"gitlab-shell","full_name":"gitlabhq/gitlab-shell","owner":{"login":"gitlabhq","id":1086321,"avatar_url":"https://avatars.githubusercontent.com/u/1086321?v=3","gravatar_id":"","url":"https://api.github.com/users/gitlabhq","html_url":"https://github.com/gitlabhq","followers_url":"https://api.github.com/users/gitlabhq/followers","following_url":"https://api.github.com/users/gitlabhq/following{/other_user}","gists_url":"https://api.github.com/users/gitlabhq/gists{/gist_id}","starred_url":"https://api.github.com/users/gitlabhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitlabhq/subscriptions","organizations_url":"https://api.github.com/users/gitlabhq/orgs","repos_url":"https://api.github.com/users/gitlabhq/repos","events_url":"https://api.github.com/users/gitlabhq/events{/privacy}","received_events_url":"https://api.github.com/users/gitlabhq/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gitlabhq/gitlab-shell","description":"Replacement for gitolite","fork":false,"url":"https://api.github.com/repos/gitlabhq/gitlab-shell","forks_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/forks","keys_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/teams","hooks_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/hooks","issue_events_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/issues/events{/number}","events_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/events","assignees_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/assignees{/user}","branches_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/branches{/branch}","tags_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/tags","blobs_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/git/refs{/sha}","trees_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/statuses/{sha}","languages_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/languages","stargazers_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/stargazers","contributors_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/contributors","subscribers_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/subscribers","subscription_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/subscription","commits_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/commits{/sha}","git_commits_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/git/commits{/sha}","comments_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/comments{/number}","issue_comment_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/issues/comments{/number}","contents_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/contents/{+path}","compare_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/merges","archive_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/downloads","issues_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/issues{/number}","pulls_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls{/number}","milestones_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/milestones{/number}","notifications_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/labels{/name}","releases_url":"https://api.github.com/repos/gitlabhq/gitlab-shell/releases{/id}","created_at":"2013-02-04T08:11:01Z","updated_at":"2015-05-27T02:08:08Z","pushed_at":"2015-06-26T10:08:28Z","git_url":"git://github.com/gitlabhq/gitlab-shell.git","ssh_url":"git@github.com:gitlabhq/gitlab-shell.git","clone_url":"https://github.com/gitlabhq/gitlab-shell.git","svn_url":"https://github.com/gitlabhq/gitlab-shell","homepage":null,"size":2000,"stargazers_count":339,"watchers_count":339,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":213,"mirror_url":null,"open_issues_count":76,"forks":213,"open_issues":76,"watchers":339,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/229"},"html":{"href":"https://github.com/gitlabhq/gitlab-shell/pull/229"},"issue":{"href":"https://api.github.com/repos/gitlabhq/gitlab-shell/issues/229"},"comments":{"href":"https://api.github.com/repos/gitlabhq/gitlab-shell/issues/229/comments"},"review_comments":{"href":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/229/comments"},"review_comment":{"href":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gitlabhq/gitlab-shell/pulls/229/commits"},"statuses":{"href":"https://api.github.com/repos/gitlabhq/gitlab-shell/statuses/96490ce52ac7394e91215616c776ca35a64a54f5"}}}}