{"action":"created","comment":{"url":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/comments/91885398","pull_request_review_id":12393773,"id":91885398,"diff_hunk":"@@ -0,0 +1,54 @@\n+module Ruboty\n+  module Capistrano\n+    class Verification\n+      class InvalidDeploySettingError < StandardError; end\n+      class NoBranchError < StandardError; end\n+\n+      include ActiveSupport::Rescuable\n+\n+      rescue_from NoBranchError, with: -> (e) { raise NoBranchError, no_branch_error(e) }\n+      rescue_from InvalidDeploySettingError, with: -> (e) { raise InvalidDeploySettingError, invalid_deploy_setting_error(e) }\n+\n+      attr_reader :env, :role, :deploy_source\n+\n+      def initialize(env:, role:, deploy_source:)\n+        @env = env\n+        @role = role\n+        @deploy_source = deploy_source\n+      end\n+\n+      def execute\n+        validate_deploy_branch_for_production\n+        validate_existence_in_github\n+      rescue => e\n+        rescue_with_handler(e)\n+      end\n+\n+      private\n+\n+      def validate_deploy_branch_for_production\n+        if env == 'production' && deploy_source.branch != 'master'\n+          raise InvalidDeploySettingError, 'production環境はmaster以外でdeploy出来ません'\n+        end\n+      end\n+\n+      def validate_existence_in_github\n+        unless deploy_source.exist_github?","path":"lib/ruboty/capistrano/verification.rb","position":36,"original_position":36,"commit_id":"561e9c0e334dae2c9eb535b2ee09a77f7cc43448","original_commit_id":"106c256e1bb254ffde4917646008423ded38e749","user":{"login":"tkm-kj","id":3395349,"avatar_url":"https://avatars.githubusercontent.com/u/3395349?v=3","gravatar_id":"","url":"https://api.github.com/users/tkm-kj","html_url":"https://github.com/tkm-kj","followers_url":"https://api.github.com/users/tkm-kj/followers","following_url":"https://api.github.com/users/tkm-kj/following{/other_user}","gists_url":"https://api.github.com/users/tkm-kj/gists{/gist_id}","starred_url":"https://api.github.com/users/tkm-kj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkm-kj/subscriptions","organizations_url":"https://api.github.com/users/tkm-kj/orgs","repos_url":"https://api.github.com/users/tkm-kj/repos","events_url":"https://api.github.com/users/tkm-kj/events{/privacy}","received_events_url":"https://api.github.com/users/tkm-kj/received_events","type":"User","site_admin":false},"body":"例えば、 `DeploySource#exist_github?` で `Octokit::NotFound` をキャッチせずに `Verification` クラスでハンドリングする方法もあるとは思うのですが、 `Verification` クラスにも `Octokit` に関する情報をもたせたくないという気持ちです。\r\nそれと独自の例外を定義したほうが、使う側としてどの箇所でどんなエラーが起きたかわかりやすくなるのかなと思っていて、その結果として冗長ですがこういうやり方を取っています。","created_at":"2016-12-12T05:37:30Z","updated_at":"2016-12-12T05:37:30Z","html_url":"https://github.com/speee/ruboty-capistrano/pull/4#discussion_r91885398","pull_request_url":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/comments/91885398"},"html":{"href":"https://github.com/speee/ruboty-capistrano/pull/4#discussion_r91885398"},"pull_request":{"href":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/4","id":96645693,"html_url":"https://github.com/speee/ruboty-capistrano/pull/4","diff_url":"https://github.com/speee/ruboty-capistrano/pull/4.diff","patch_url":"https://github.com/speee/ruboty-capistrano/pull/4.patch","issue_url":"https://api.github.com/repos/speee/ruboty-capistrano/issues/4","number":4,"state":"open","locked":false,"title":"リポジトリにデプロイブランチが存在しない時にその旨を通知するようにした","user":{"login":"tkm-kj","id":3395349,"avatar_url":"https://avatars.githubusercontent.com/u/3395349?v=3","gravatar_id":"","url":"https://api.github.com/users/tkm-kj","html_url":"https://github.com/tkm-kj","followers_url":"https://api.github.com/users/tkm-kj/followers","following_url":"https://api.github.com/users/tkm-kj/following{/other_user}","gists_url":"https://api.github.com/users/tkm-kj/gists{/gist_id}","starred_url":"https://api.github.com/users/tkm-kj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkm-kj/subscriptions","organizations_url":"https://api.github.com/users/tkm-kj/orgs","repos_url":"https://api.github.com/users/tkm-kj/repos","events_url":"https://api.github.com/users/tkm-kj/events{/privacy}","received_events_url":"https://api.github.com/users/tkm-kj/received_events","type":"User","site_admin":false},"body":"そのリポジトリに存在しないブランチをデプロイしようとした時に、ブランチが存在しない旨を通知するようにしました。\r\n\r\n<img width=\"623\" alt=\"_2016-12-06_10_36_00\" src=\"https://cloud.githubusercontent.com/assets/3395349/20909702/9b3eb414-bba0-11e6-84ff-cc3fe5330835.png\">\r\n<img width=\"454\" alt=\"slack_-_speee\" src=\"https://cloud.githubusercontent.com/assets/3395349/20909706/9fd4e8c2-bba0-11e6-9a23-f91e3de2ba08.png\">\r\n\r\n追加で必要な設定はREADMEにあります。","created_at":"2016-12-06T01:44:44Z","updated_at":"2016-12-12T05:37:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fbb1f438ced377e24125c5806d407dbd971f233","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/4/commits","review_comments_url":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/4/comments","review_comment_url":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/comments{/number}","comments_url":"https://api.github.com/repos/speee/ruboty-capistrano/issues/4/comments","statuses_url":"https://api.github.com/repos/speee/ruboty-capistrano/statuses/561e9c0e334dae2c9eb535b2ee09a77f7cc43448","head":{"label":"tkm-kj:rescue_branch_not_found_exception","ref":"rescue_branch_not_found_exception","sha":"561e9c0e334dae2c9eb535b2ee09a77f7cc43448","user":{"login":"tkm-kj","id":3395349,"avatar_url":"https://avatars.githubusercontent.com/u/3395349?v=3","gravatar_id":"","url":"https://api.github.com/users/tkm-kj","html_url":"https://github.com/tkm-kj","followers_url":"https://api.github.com/users/tkm-kj/followers","following_url":"https://api.github.com/users/tkm-kj/following{/other_user}","gists_url":"https://api.github.com/users/tkm-kj/gists{/gist_id}","starred_url":"https://api.github.com/users/tkm-kj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkm-kj/subscriptions","organizations_url":"https://api.github.com/users/tkm-kj/orgs","repos_url":"https://api.github.com/users/tkm-kj/repos","events_url":"https://api.github.com/users/tkm-kj/events{/privacy}","received_events_url":"https://api.github.com/users/tkm-kj/received_events","type":"User","site_admin":false},"repo":{"id":74380192,"name":"ruboty-capistrano","full_name":"tkm-kj/ruboty-capistrano","owner":{"login":"tkm-kj","id":3395349,"avatar_url":"https://avatars.githubusercontent.com/u/3395349?v=3","gravatar_id":"","url":"https://api.github.com/users/tkm-kj","html_url":"https://github.com/tkm-kj","followers_url":"https://api.github.com/users/tkm-kj/followers","following_url":"https://api.github.com/users/tkm-kj/following{/other_user}","gists_url":"https://api.github.com/users/tkm-kj/gists{/gist_id}","starred_url":"https://api.github.com/users/tkm-kj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkm-kj/subscriptions","organizations_url":"https://api.github.com/users/tkm-kj/orgs","repos_url":"https://api.github.com/users/tkm-kj/repos","events_url":"https://api.github.com/users/tkm-kj/events{/privacy}","received_events_url":"https://api.github.com/users/tkm-kj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tkm-kj/ruboty-capistrano","description":"ruboty capistrano plugin","fork":true,"url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano","forks_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/forks","keys_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/teams","hooks_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/hooks","issue_events_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/issues/events{/number}","events_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/events","assignees_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/assignees{/user}","branches_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/branches{/branch}","tags_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/tags","blobs_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/git/refs{/sha}","trees_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/statuses/{sha}","languages_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/languages","stargazers_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/stargazers","contributors_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/contributors","subscribers_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/subscribers","subscription_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/subscription","commits_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/commits{/sha}","git_commits_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/git/commits{/sha}","comments_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/comments{/number}","issue_comment_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/issues/comments{/number}","contents_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/contents/{+path}","compare_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/merges","archive_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/downloads","issues_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/issues{/number}","pulls_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/pulls{/number}","milestones_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/milestones{/number}","notifications_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/labels{/name}","releases_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/releases{/id}","deployments_url":"https://api.github.com/repos/tkm-kj/ruboty-capistrano/deployments","created_at":"2016-11-21T15:58:22Z","updated_at":"2016-11-21T15:58:23Z","pushed_at":"2016-12-12T05:03:30Z","git_url":"git://github.com/tkm-kj/ruboty-capistrano.git","ssh_url":"git@github.com:tkm-kj/ruboty-capistrano.git","clone_url":"https://github.com/tkm-kj/ruboty-capistrano.git","svn_url":"https://github.com/tkm-kj/ruboty-capistrano","homepage":null,"size":38,"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":"speee:master","ref":"master","sha":"532318680b7239dc0e2bc0e24e651aef6ac11804","user":{"login":"speee","id":12638362,"avatar_url":"https://avatars.githubusercontent.com/u/12638362?v=3","gravatar_id":"","url":"https://api.github.com/users/speee","html_url":"https://github.com/speee","followers_url":"https://api.github.com/users/speee/followers","following_url":"https://api.github.com/users/speee/following{/other_user}","gists_url":"https://api.github.com/users/speee/gists{/gist_id}","starred_url":"https://api.github.com/users/speee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/speee/subscriptions","organizations_url":"https://api.github.com/users/speee/orgs","repos_url":"https://api.github.com/users/speee/repos","events_url":"https://api.github.com/users/speee/events{/privacy}","received_events_url":"https://api.github.com/users/speee/received_events","type":"Organization","site_admin":false},"repo":{"id":61934082,"name":"ruboty-capistrano","full_name":"speee/ruboty-capistrano","owner":{"login":"speee","id":12638362,"avatar_url":"https://avatars.githubusercontent.com/u/12638362?v=3","gravatar_id":"","url":"https://api.github.com/users/speee","html_url":"https://github.com/speee","followers_url":"https://api.github.com/users/speee/followers","following_url":"https://api.github.com/users/speee/following{/other_user}","gists_url":"https://api.github.com/users/speee/gists{/gist_id}","starred_url":"https://api.github.com/users/speee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/speee/subscriptions","organizations_url":"https://api.github.com/users/speee/orgs","repos_url":"https://api.github.com/users/speee/repos","events_url":"https://api.github.com/users/speee/events{/privacy}","received_events_url":"https://api.github.com/users/speee/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/speee/ruboty-capistrano","description":"ruboty capistrano plugin","fork":false,"url":"https://api.github.com/repos/speee/ruboty-capistrano","forks_url":"https://api.github.com/repos/speee/ruboty-capistrano/forks","keys_url":"https://api.github.com/repos/speee/ruboty-capistrano/keys{/key_id}","collaborators_url":"https://api.github.com/repos/speee/ruboty-capistrano/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/speee/ruboty-capistrano/teams","hooks_url":"https://api.github.com/repos/speee/ruboty-capistrano/hooks","issue_events_url":"https://api.github.com/repos/speee/ruboty-capistrano/issues/events{/number}","events_url":"https://api.github.com/repos/speee/ruboty-capistrano/events","assignees_url":"https://api.github.com/repos/speee/ruboty-capistrano/assignees{/user}","branches_url":"https://api.github.com/repos/speee/ruboty-capistrano/branches{/branch}","tags_url":"https://api.github.com/repos/speee/ruboty-capistrano/tags","blobs_url":"https://api.github.com/repos/speee/ruboty-capistrano/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/speee/ruboty-capistrano/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/speee/ruboty-capistrano/git/refs{/sha}","trees_url":"https://api.github.com/repos/speee/ruboty-capistrano/git/trees{/sha}","statuses_url":"https://api.github.com/repos/speee/ruboty-capistrano/statuses/{sha}","languages_url":"https://api.github.com/repos/speee/ruboty-capistrano/languages","stargazers_url":"https://api.github.com/repos/speee/ruboty-capistrano/stargazers","contributors_url":"https://api.github.com/repos/speee/ruboty-capistrano/contributors","subscribers_url":"https://api.github.com/repos/speee/ruboty-capistrano/subscribers","subscription_url":"https://api.github.com/repos/speee/ruboty-capistrano/subscription","commits_url":"https://api.github.com/repos/speee/ruboty-capistrano/commits{/sha}","git_commits_url":"https://api.github.com/repos/speee/ruboty-capistrano/git/commits{/sha}","comments_url":"https://api.github.com/repos/speee/ruboty-capistrano/comments{/number}","issue_comment_url":"https://api.github.com/repos/speee/ruboty-capistrano/issues/comments{/number}","contents_url":"https://api.github.com/repos/speee/ruboty-capistrano/contents/{+path}","compare_url":"https://api.github.com/repos/speee/ruboty-capistrano/compare/{base}...{head}","merges_url":"https://api.github.com/repos/speee/ruboty-capistrano/merges","archive_url":"https://api.github.com/repos/speee/ruboty-capistrano/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/speee/ruboty-capistrano/downloads","issues_url":"https://api.github.com/repos/speee/ruboty-capistrano/issues{/number}","pulls_url":"https://api.github.com/repos/speee/ruboty-capistrano/pulls{/number}","milestones_url":"https://api.github.com/repos/speee/ruboty-capistrano/milestones{/number}","notifications_url":"https://api.github.com/repos/speee/ruboty-capistrano/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/speee/ruboty-capistrano/labels{/name}","releases_url":"https://api.github.com/repos/speee/ruboty-capistrano/releases{/id}","deployments_url":"https://api.github.com/repos/speee/ruboty-capistrano/deployments","created_at":"2016-06-25T08:27:12Z","updated_at":"2016-12-05T10:12:22Z","pushed_at":"2016-12-12T05:03:30Z","git_url":"git://github.com/speee/ruboty-capistrano.git","ssh_url":"git@github.com:speee/ruboty-capistrano.git","clone_url":"https://github.com/speee/ruboty-capistrano.git","svn_url":"https://github.com/speee/ruboty-capistrano","homepage":null,"size":20,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/4"},"html":{"href":"https://github.com/speee/ruboty-capistrano/pull/4"},"issue":{"href":"https://api.github.com/repos/speee/ruboty-capistrano/issues/4"},"comments":{"href":"https://api.github.com/repos/speee/ruboty-capistrano/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/speee/ruboty-capistrano/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/speee/ruboty-capistrano/statuses/561e9c0e334dae2c9eb535b2ee09a77f7cc43448"}}}}
{"actor":{"display_login":"tkm-kj"}}