GitHub PullRequestReviewCommentEvent at 2014-07-29 16:17:28
Repository: gitlabhq
Actor: houndci
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/comments/15533878","id":15533878,"diff_hunk":"@@ -0,0 +1,82 @@\n+# == Schema Information\n+#\n+# Table name: services\n+#\n+#  id          :integer          not null, primary key\n+#  type        :string(255)\n+#  title       :string(255)\n+#  token       :string(255)\n+#  project_id  :integer          not null\n+#  created_at  :datetime\n+#  updated_at  :datetime\n+#  active      :boolean          default(FALSE), not null\n+#  project_url :string(255)\n+#  subdomain   :string(255)\n+#  room        :string(255)\n+#  recipients  :text\n+#  api_key     :string(255)\n+#\n+\n+require 'asana'\n+\n+class AsanaService < Service\n+  validates :api_key, presence: true, if: :activated?\n+\n+  def title\n+    'Asana'\n+  end\n+\n+  def description\n+    'Asana - Teamwork without email'\n+  end\n+\n+  def to_param\n+    'asana'\n+  end\n+\n+  def fields\n+    [\n+      { type: 'text', name: 'api_key', placeholder: '' }\n+    ]\n+  end\n+\n+  def execute(push)\n+    Asana.configure do |client|\n+      client.api_key = api_key\n+    end\n+\n+    user = push[:user_name]\n+    branch = push[:ref].gsub('refs/heads/', '')\n+    project_name = project.name_with_namespace\n+    push_msg = user + ' pushed to branch ' + branch + ' of ' + project_name\n+\n+    push[:commits].each do |commit|\n+      check_commit(' (#{commit[:url]})\\n#{commit[:message]}', push_msg)\n+    end\n+  end\n+\n+  def check_commit(message, push_msg)\n+    task_list = []\n+    close_list = []\n+\n+    message.split(\"\\n\").each do |line|\n+      # look for a task ID or a full Asana url\n+      task_list.concat(line.scan(/#(\\d+)/))\n+      task_list.concat(line.scan(/https:\\/\\/app\\.asana\\.com\\/\\d+\\/\\d+\\/(\\d+)/))\n+      # look for a word starting with 'fix' followed by a task ID\n+      close_list.concat(line.scan(/(fix\\w*)\\W*#(\\d+)/i))\n+    end\n+\n+    # post commit to every taskid found\n+    task_list.each do |taskid|\n+      task = Asana::Task.find(taskid[0])\n+      task.create_story(:text: '#{push_msg} #{message}')\n+    end\n+\n+    # close all tasks that had 'fix(ed/es/ing) #:id' in them\n+    close_list.each do |taskid|\n+      task = Asana::Task.find(taskid.last)\n+      task.modify(:completed: true)","path":"app/models/project_services/asana_service.rb","position":79,"original_position":79,"commit_id":"4dce795d0f364b5bd40faaa81c4ae90521c33c35","original_commit_id":"4dce795d0f364b5bd40faaa81c4ae90521c33c35","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?","gravatar_id":"38d9cefd9971a05bf447f07c6cd332cc","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":"unexpected token tCOLON","created_at":"2014-07-29T16:17:28Z","updated_at":"2014-07-29T16:17:28Z","html_url":"https://github.com/gitlabhq/gitlabhq/pull/7394#discussion_r15533878","pull_request_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7394","_links":{"self":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/comments/15533878"},"html":{"href":"https://github.com/gitlabhq/gitlabhq/pull/7394#discussion_r15533878"},"pull_request":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7394"}}},"pull_request":{"url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7394","id":19035621,"html_url":"https://github.com/gitlabhq/gitlabhq/pull/7394","diff_url":"https://github.com/gitlabhq/gitlabhq/pull/7394.diff","patch_url":"https://github.com/gitlabhq/gitlabhq/pull/7394.patch","issue_url":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/7394","number":7394,"state":"open","title":"Add Asana integration","user":{"login":"j0k3r","id":62333,"avatar_url":"https://avatars.githubusercontent.com/u/62333?","gravatar_id":"aee3b44e5f0b4dfa0e2da672897b3751","url":"https://api.github.com/users/j0k3r","html_url":"https://github.com/j0k3r","followers_url":"https://api.github.com/users/j0k3r/followers","following_url":"https://api.github.com/users/j0k3r/following{/other_user}","gists_url":"https://api.github.com/users/j0k3r/gists{/gist_id}","starred_url":"https://api.github.com/users/j0k3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j0k3r/subscriptions","organizations_url":"https://api.github.com/users/j0k3r/orgs","repos_url":"https://api.github.com/users/j0k3r/repos","events_url":"https://api.github.com/users/j0k3r/events{/privacy}","received_events_url":"https://api.github.com/users/j0k3r/received_events","type":"User","site_admin":false},"body":"**This is a work in progress.** And I created this PR early to let you know that I'm working on an Asana integration.\r\n\r\n----\r\n\r\n**What does this MR do?**\r\n\r\nWhen someone commit with a message including\r\n\r\n - \"blabla #123456\", it will attach a new message to the task 123456 in Asana.\r\n - \"fix #456789\", it will attach a new message and close (mark as done) the task 456789 in Asana\r\n\r\n**Are there points in the code the reviewer needs to double check?**\r\n\r\nI guess `app/models/project_services/asana_service.rb`\r\n\r\n**Why was this MR needed?**\r\n\r\nWe use Asana as our Issue tracking system. It will ease the relation between Asana and Gitlab by linking Asana tickets to git commit.\r\n\r\n**What are the relevant issue numbers / Feature requests?**\r\n\r\nNope.\r\n\r\n**Screenshots (If appropiate)**\r\n\r\nWIP :wink: ","created_at":"2014-07-29T15:52:50Z","updated_at":"2014-07-29T16:17:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c57e261da3f7dde727ddcc829390edf1dad9781","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7394/commits","review_comments_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7394/comments","review_comment_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/comments/{number}","comments_url":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/7394/comments","statuses_url":"https://api.github.com/repos/gitlabhq/gitlabhq/statuses/4dce795d0f364b5bd40faaa81c4ae90521c33c35","head":{"label":"j0k3r:asana","ref":"asana","sha":"4dce795d0f364b5bd40faaa81c4ae90521c33c35","user":{"login":"j0k3r","id":62333,"avatar_url":"https://avatars.githubusercontent.com/u/62333?","gravatar_id":"aee3b44e5f0b4dfa0e2da672897b3751","url":"https://api.github.com/users/j0k3r","html_url":"https://github.com/j0k3r","followers_url":"https://api.github.com/users/j0k3r/followers","following_url":"https://api.github.com/users/j0k3r/following{/other_user}","gists_url":"https://api.github.com/users/j0k3r/gists{/gist_id}","starred_url":"https://api.github.com/users/j0k3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j0k3r/subscriptions","organizations_url":"https://api.github.com/users/j0k3r/orgs","repos_url":"https://api.github.com/users/j0k3r/repos","events_url":"https://api.github.com/users/j0k3r/events{/privacy}","received_events_url":"https://api.github.com/users/j0k3r/received_events","type":"User","site_admin":false},"repo":{"id":22383733,"name":"gitlabhq","full_name":"j0k3r/gitlabhq","owner":{"login":"j0k3r","id":62333,"avatar_url":"https://avatars.githubusercontent.com/u/62333?","gravatar_id":"aee3b44e5f0b4dfa0e2da672897b3751","url":"https://api.github.com/users/j0k3r","html_url":"https://github.com/j0k3r","followers_url":"https://api.github.com/users/j0k3r/followers","following_url":"https://api.github.com/users/j0k3r/following{/other_user}","gists_url":"https://api.github.com/users/j0k3r/gists{/gist_id}","starred_url":"https://api.github.com/users/j0k3r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j0k3r/subscriptions","organizations_url":"https://api.github.com/users/j0k3r/orgs","repos_url":"https://api.github.com/users/j0k3r/repos","events_url":"https://api.github.com/users/j0k3r/events{/privacy}","received_events_url":"https://api.github.com/users/j0k3r/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/j0k3r/gitlabhq","description":"Open source software to collaborate on code. Follow us on twitter @gitlabhq","fork":true,"url":"https://api.github.com/repos/j0k3r/gitlabhq","forks_url":"https://api.github.com/repos/j0k3r/gitlabhq/forks","keys_url":"https://api.github.com/repos/j0k3r/gitlabhq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/j0k3r/gitlabhq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/j0k3r/gitlabhq/teams","hooks_url":"https://api.github.com/repos/j0k3r/gitlabhq/hooks","issue_events_url":"https://api.github.com/repos/j0k3r/gitlabhq/issues/events{/number}","events_url":"https://api.github.com/repos/j0k3r/gitlabhq/events","assignees_url":"https://api.github.com/repos/j0k3r/gitlabhq/assignees{/user}","branches_url":"https://api.github.com/repos/j0k3r/gitlabhq/branches{/branch}","tags_url":"https://api.github.com/repos/j0k3r/gitlabhq/tags","blobs_url":"https://api.github.com/repos/j0k3r/gitlabhq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/j0k3r/gitlabhq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/j0k3r/gitlabhq/git/refs{/sha}","trees_url":"https://api.github.com/repos/j0k3r/gitlabhq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/j0k3r/gitlabhq/statuses/{sha}","languages_url":"https://api.github.com/repos/j0k3r/gitlabhq/languages","stargazers_url":"https://api.github.com/repos/j0k3r/gitlabhq/stargazers","contributors_url":"https://api.github.com/repos/j0k3r/gitlabhq/contributors","subscribers_url":"https://api.github.com/repos/j0k3r/gitlabhq/subscribers","subscription_url":"https://api.github.com/repos/j0k3r/gitlabhq/subscription","commits_url":"https://api.github.com/repos/j0k3r/gitlabhq/commits{/sha}","git_commits_url":"https://api.github.com/repos/j0k3r/gitlabhq/git/commits{/sha}","comments_url":"https://api.github.com/repos/j0k3r/gitlabhq/comments{/number}","issue_comment_url":"https://api.github.com/repos/j0k3r/gitlabhq/issues/comments/{number}","contents_url":"https://api.github.com/repos/j0k3r/gitlabhq/contents/{+path}","compare_url":"https://api.github.com/repos/j0k3r/gitlabhq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/j0k3r/gitlabhq/merges","archive_url":"https://api.github.com/repos/j0k3r/gitlabhq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/j0k3r/gitlabhq/downloads","issues_url":"https://api.github.com/repos/j0k3r/gitlabhq/issues{/number}","pulls_url":"https://api.github.com/repos/j0k3r/gitlabhq/pulls{/number}","milestones_url":"https://api.github.com/repos/j0k3r/gitlabhq/milestones{/number}","notifications_url":"https://api.github.com/repos/j0k3r/gitlabhq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/j0k3r/gitlabhq/labels{/name}","releases_url":"https://api.github.com/repos/j0k3r/gitlabhq/releases{/id}","created_at":"2014-07-29T14:58:10Z","updated_at":"2014-07-29T14:54:37Z","pushed_at":"2014-07-29T16:17:19Z","git_url":"git://github.com/j0k3r/gitlabhq.git","ssh_url":"git@github.com:j0k3r/gitlabhq.git","clone_url":"https://github.com/j0k3r/gitlabhq.git","svn_url":"https://github.com/j0k3r/gitlabhq","homepage":"https://about.gitlab.com/","size":139159,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"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":"535feb08ce90352c89799df5e3e70a10e53ee10d","user":{"login":"gitlabhq","id":1086321,"avatar_url":"https://avatars.githubusercontent.com/u/1086321?","gravatar_id":"95b7f387358639ec09184a76151bc690","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":2500088,"name":"gitlabhq","full_name":"gitlabhq/gitlabhq","owner":{"login":"gitlabhq","id":1086321,"avatar_url":"https://avatars.githubusercontent.com/u/1086321?","gravatar_id":"95b7f387358639ec09184a76151bc690","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/gitlabhq","description":"Open source software to collaborate on code. Follow us on twitter @gitlabhq","fork":false,"url":"https://api.github.com/repos/gitlabhq/gitlabhq","forks_url":"https://api.github.com/repos/gitlabhq/gitlabhq/forks","keys_url":"https://api.github.com/repos/gitlabhq/gitlabhq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gitlabhq/gitlabhq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gitlabhq/gitlabhq/teams","hooks_url":"https://api.github.com/repos/gitlabhq/gitlabhq/hooks","issue_events_url":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/events{/number}","events_url":"https://api.github.com/repos/gitlabhq/gitlabhq/events","assignees_url":"https://api.github.com/repos/gitlabhq/gitlabhq/assignees{/user}","branches_url":"https://api.github.com/repos/gitlabhq/gitlabhq/branches{/branch}","tags_url":"https://api.github.com/repos/gitlabhq/gitlabhq/tags","blobs_url":"https://api.github.com/repos/gitlabhq/gitlabhq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gitlabhq/gitlabhq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gitlabhq/gitlabhq/git/refs{/sha}","trees_url":"https://api.github.com/repos/gitlabhq/gitlabhq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gitlabhq/gitlabhq/statuses/{sha}","languages_url":"https://api.github.com/repos/gitlabhq/gitlabhq/languages","stargazers_url":"https://api.github.com/repos/gitlabhq/gitlabhq/stargazers","contributors_url":"https://api.github.com/repos/gitlabhq/gitlabhq/contributors","subscribers_url":"https://api.github.com/repos/gitlabhq/gitlabhq/subscribers","subscription_url":"https://api.github.com/repos/gitlabhq/gitlabhq/subscription","commits_url":"https://api.github.com/repos/gitlabhq/gitlabhq/commits{/sha}","git_commits_url":"https://api.github.com/repos/gitlabhq/gitlabhq/git/commits{/sha}","comments_url":"https://api.github.com/repos/gitlabhq/gitlabhq/comments{/number}","issue_comment_url":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/comments/{number}","contents_url":"https://api.github.com/repos/gitlabhq/gitlabhq/contents/{+path}","compare_url":"https://api.github.com/repos/gitlabhq/gitlabhq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gitlabhq/gitlabhq/merges","archive_url":"https://api.github.com/repos/gitlabhq/gitlabhq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gitlabhq/gitlabhq/downloads","issues_url":"https://api.github.com/repos/gitlabhq/gitlabhq/issues{/number}","pulls_url":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls{/number}","milestones_url":"https://api.github.com/repos/gitlabhq/gitlabhq/milestones{/number}","notifications_url":"https://api.github.com/repos/gitlabhq/gitlabhq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gitlabhq/gitlabhq/labels{/name}","releases_url":"https://api.github.com/repos/gitlabhq/gitlabhq/releases{/id}","created_at":"2011-10-02T16:25:27Z","updated_at":"2014-07-29T14:54:37Z","pushed_at":"2014-07-29T12:18:55Z","git_url":"git://github.com/gitlabhq/gitlabhq.git","ssh_url":"git@github.com:gitlabhq/gitlabhq.git","clone_url":"https://github.com/gitlabhq/gitlabhq.git","svn_url":"https://github.com/gitlabhq/gitlabhq","homepage":"https://about.gitlab.com/","size":139159,"stargazers_count":13598,"watchers_count":13598,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":3520,"mirror_url":null,"open_issues_count":458,"forks":3520,"open_issues":458,"watchers":13598,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7394"},"html":{"href":"https://github.com/gitlabhq/gitlabhq/pull/7394"},"issue":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/7394"},"comments":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/issues/7394/comments"},"review_comments":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7394/comments"},"review_comment":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/pulls/7394/commits"},"statuses":{"href":"https://api.github.com/repos/gitlabhq/gitlabhq/statuses/4dce795d0f364b5bd40faaa81c4ae90521c33c35"}}}}