{"action":"created","comment":{"url":"https://api.github.com/repos/xulaus/mr_bump/pulls/comments/75594861","id":75594861,"diff_hunk":"@@ -16,31 +21,85 @@ def bump(version, changes)\n       options = {}\n       options[:icon_url] = @icon if @icon\n       options[:attachments] = [attatchment(version, changes)]\n-      notifier.ping ' ', options\n+      notifier.ping 'There is a new version bump!', options\n+    end\n+\n+    def notifier\n+      @notifier ||= ::Slack::Notifier.new(@webhook, username: @username)\n     end\n \n     def user\n-      [\n-        ENV[\"USER\"],\n-        `whoami`\n-      ].detect { |u| !u.nil? }\n+      `git config user.name`.gsub(/\\n/, '')\n+    end\n+\n+    def git_url\n+      @git_url ||= `git remote get-url origin`\n+    end\n+\n+    def git_user\n+      git_url[/[^@]+/].partition('//').last\n+    end\n+\n+    def git_icon\n+      'https://avatars.githubusercontent.com/' + git_user\n+    end\n+\n+    def git_link\n+      'https://github.com/' + git_user\n     end\n \n     def repo_name\n       `git config --get remote.origin.url`[/[\\w\\.]+(?=\\.git$)/]\n     end\n \n-    def notifier\n-      @notifier ||= ::Slack::Notifier.new(@webhook, username: @username)\n+    def jira_ids(changes)\n+      changes.split('* ').map { |i| i.split(' - ',3)[1]}.compact\n+    end\n+\n+    def jira_urls(changes)\n+      jira_ids(changes).map do |ticket|\n+        if ticket!= 'UNKNOWN'\n+          '<' + @jira_url + '/browse/' + ticket + '|Jira link - ' + ticket + \">\\n\"\n+        end\n+      end.join\n     end\n \n+    def jira_field(changes)\n+      if @jira_url != nil\n+        {value: jira_urls(changes), short: true, unfurl_links: false}\n+      end\n+    end\n+\n+    def get_sha(id)\n+      `git log --grep=#{id} --merges --format=format:%H`.split(\"\\n\").first\n+    end\n+\n+    def git_repo_url\n+      'https://' + git_url.partition('@').last.gsub(\".git\\n\", '')\n+    end\n+\n+    def git_shas(changes)\n+      jira_ids(changes).map do |ticket|\n+        if ticket!= 'UNKNOWN'\n+          '<' + git_repo_url + '/commit/'  + get_sha(ticket) + '|Git merge link - ' + ticket + \">\\n\"\n+        end\n+      end.join\n+    end\n+\n+\n     def attatchment(version, changes)\n       {\n-        title: \"#{user} has bumped #{repo_name}\",\n         fallback: changes,\n+        color: \"#009de4\",\n+        author_name: user,\n+        author_icon: git_icon,\n+        author_link: git_link,\n         fields: [\n-                  {title: 'Version', value: version},\n-                  {title: 'Change Log', value: changes}\n+                  {title: 'Version', value: version, short: true},\n+                  {title: 'Repository', value: repo_name, short: true},\n+                  {title: 'Change Log', value: changes, short: false},\n+                  jira_field(changes),","path":"lib/mr_bump/slack.rb","position":107,"original_position":107,"commit_id":"e4792cbe601f04b5838ae5a81aabb129f841e4a9","original_commit_id":"e4792cbe601f04b5838ae5a81aabb129f841e4a9","user":{"login":"jbryant92","id":18394119,"avatar_url":"https://avatars.githubusercontent.com/u/18394119?v=3","gravatar_id":"","url":"https://api.github.com/users/jbryant92","html_url":"https://github.com/jbryant92","followers_url":"https://api.github.com/users/jbryant92/followers","following_url":"https://api.github.com/users/jbryant92/following{/other_user}","gists_url":"https://api.github.com/users/jbryant92/gists{/gist_id}","starred_url":"https://api.github.com/users/jbryant92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbryant92/subscriptions","organizations_url":"https://api.github.com/users/jbryant92/orgs","repos_url":"https://api.github.com/users/jbryant92/repos","events_url":"https://api.github.com/users/jbryant92/events{/privacy}","received_events_url":"https://api.github.com/users/jbryant92/received_events","type":"User","site_admin":false},"body":"Yeah I checked, it works fine.","created_at":"2016-08-21T13:01:26Z","updated_at":"2016-08-21T13:01:26Z","html_url":"https://github.com/xulaus/mr_bump/pull/5#discussion_r75594861","pull_request_url":"https://api.github.com/repos/xulaus/mr_bump/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/xulaus/mr_bump/pulls/comments/75594861"},"html":{"href":"https://github.com/xulaus/mr_bump/pull/5#discussion_r75594861"},"pull_request":{"href":"https://api.github.com/repos/xulaus/mr_bump/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/xulaus/mr_bump/pulls/5","id":82104195,"html_url":"https://github.com/xulaus/mr_bump/pull/5","diff_url":"https://github.com/xulaus/mr_bump/pull/5.diff","patch_url":"https://github.com/xulaus/mr_bump/pull/5.patch","issue_url":"https://api.github.com/repos/xulaus/mr_bump/issues/5","number":5,"state":"open","locked":false,"title":"Add a number of new features to Slack Integration","user":{"login":"jbryant92","id":18394119,"avatar_url":"https://avatars.githubusercontent.com/u/18394119?v=3","gravatar_id":"","url":"https://api.github.com/users/jbryant92","html_url":"https://github.com/jbryant92","followers_url":"https://api.github.com/users/jbryant92/followers","following_url":"https://api.github.com/users/jbryant92/following{/other_user}","gists_url":"https://api.github.com/users/jbryant92/gists{/gist_id}","starred_url":"https://api.github.com/users/jbryant92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbryant92/subscriptions","organizations_url":"https://api.github.com/users/jbryant92/orgs","repos_url":"https://api.github.com/users/jbryant92/repos","events_url":"https://api.github.com/users/jbryant92/events{/privacy}","received_events_url":"https://api.github.com/users/jbryant92/received_events","type":"User","site_admin":false},"body":"**This pull request will make the following changes mainly to the Slack Integration:**\r\n\r\n- Name displayed will now be the Git user name\r\n- Git user profile picture will be displayed on the post\r\n- Clicking the git username will take you to the users profile\r\n- Reformatted the post layout, now includes a message that comes as slack push notification\r\n- When changes are manually edited, this is reflected in the slack post\r\n- Give the user a chance to review manually edited changelog entries after exiting nano\r\n- Mr Bump now generates JIRA links from JIRA IDs and places them in the post (this is configurable, from the .mr_bump config)\r\n- Mr Bump now also creates links to the merge commits relating to the story and places them in the post\r\n\r\nSince we now have this information, we should think to put JIRA links and Git links in the changelog to make it more interactive. The Syntax is very simple. \r\n\r\n**Example new post:**\r\n\r\n![image](https://cloud.githubusercontent.com/assets/18394119/17837088/de64e23a-67a0-11e6-8e1f-b31d438a672d.png)\r\n","created_at":"2016-08-21T12:12:47Z","updated_at":"2016-08-21T13:01:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc045db4b6fb83f1a8ae9a40cb7fd6d442c68fad","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/xulaus/mr_bump/pulls/5/commits","review_comments_url":"https://api.github.com/repos/xulaus/mr_bump/pulls/5/comments","review_comment_url":"https://api.github.com/repos/xulaus/mr_bump/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xulaus/mr_bump/issues/5/comments","statuses_url":"https://api.github.com/repos/xulaus/mr_bump/statuses/e4792cbe601f04b5838ae5a81aabb129f841e4a9","head":{"label":"xulaus:feature/slack_upgrade","ref":"feature/slack_upgrade","sha":"e4792cbe601f04b5838ae5a81aabb129f841e4a9","user":{"login":"xulaus","id":9027149,"avatar_url":"https://avatars.githubusercontent.com/u/9027149?v=3","gravatar_id":"","url":"https://api.github.com/users/xulaus","html_url":"https://github.com/xulaus","followers_url":"https://api.github.com/users/xulaus/followers","following_url":"https://api.github.com/users/xulaus/following{/other_user}","gists_url":"https://api.github.com/users/xulaus/gists{/gist_id}","starred_url":"https://api.github.com/users/xulaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xulaus/subscriptions","organizations_url":"https://api.github.com/users/xulaus/orgs","repos_url":"https://api.github.com/users/xulaus/repos","events_url":"https://api.github.com/users/xulaus/events{/privacy}","received_events_url":"https://api.github.com/users/xulaus/received_events","type":"User","site_admin":false},"repo":{"id":65999244,"name":"mr_bump","full_name":"xulaus/mr_bump","owner":{"login":"xulaus","id":9027149,"avatar_url":"https://avatars.githubusercontent.com/u/9027149?v=3","gravatar_id":"","url":"https://api.github.com/users/xulaus","html_url":"https://github.com/xulaus","followers_url":"https://api.github.com/users/xulaus/followers","following_url":"https://api.github.com/users/xulaus/following{/other_user}","gists_url":"https://api.github.com/users/xulaus/gists{/gist_id}","starred_url":"https://api.github.com/users/xulaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xulaus/subscriptions","organizations_url":"https://api.github.com/users/xulaus/orgs","repos_url":"https://api.github.com/users/xulaus/repos","events_url":"https://api.github.com/users/xulaus/events{/privacy}","received_events_url":"https://api.github.com/users/xulaus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xulaus/mr_bump","description":"Tool for versioning git flow projects","fork":false,"url":"https://api.github.com/repos/xulaus/mr_bump","forks_url":"https://api.github.com/repos/xulaus/mr_bump/forks","keys_url":"https://api.github.com/repos/xulaus/mr_bump/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xulaus/mr_bump/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xulaus/mr_bump/teams","hooks_url":"https://api.github.com/repos/xulaus/mr_bump/hooks","issue_events_url":"https://api.github.com/repos/xulaus/mr_bump/issues/events{/number}","events_url":"https://api.github.com/repos/xulaus/mr_bump/events","assignees_url":"https://api.github.com/repos/xulaus/mr_bump/assignees{/user}","branches_url":"https://api.github.com/repos/xulaus/mr_bump/branches{/branch}","tags_url":"https://api.github.com/repos/xulaus/mr_bump/tags","blobs_url":"https://api.github.com/repos/xulaus/mr_bump/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xulaus/mr_bump/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xulaus/mr_bump/git/refs{/sha}","trees_url":"https://api.github.com/repos/xulaus/mr_bump/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xulaus/mr_bump/statuses/{sha}","languages_url":"https://api.github.com/repos/xulaus/mr_bump/languages","stargazers_url":"https://api.github.com/repos/xulaus/mr_bump/stargazers","contributors_url":"https://api.github.com/repos/xulaus/mr_bump/contributors","subscribers_url":"https://api.github.com/repos/xulaus/mr_bump/subscribers","subscription_url":"https://api.github.com/repos/xulaus/mr_bump/subscription","commits_url":"https://api.github.com/repos/xulaus/mr_bump/commits{/sha}","git_commits_url":"https://api.github.com/repos/xulaus/mr_bump/git/commits{/sha}","comments_url":"https://api.github.com/repos/xulaus/mr_bump/comments{/number}","issue_comment_url":"https://api.github.com/repos/xulaus/mr_bump/issues/comments{/number}","contents_url":"https://api.github.com/repos/xulaus/mr_bump/contents/{+path}","compare_url":"https://api.github.com/repos/xulaus/mr_bump/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xulaus/mr_bump/merges","archive_url":"https://api.github.com/repos/xulaus/mr_bump/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xulaus/mr_bump/downloads","issues_url":"https://api.github.com/repos/xulaus/mr_bump/issues{/number}","pulls_url":"https://api.github.com/repos/xulaus/mr_bump/pulls{/number}","milestones_url":"https://api.github.com/repos/xulaus/mr_bump/milestones{/number}","notifications_url":"https://api.github.com/repos/xulaus/mr_bump/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xulaus/mr_bump/labels{/name}","releases_url":"https://api.github.com/repos/xulaus/mr_bump/releases{/id}","deployments_url":"https://api.github.com/repos/xulaus/mr_bump/deployments","created_at":"2016-08-18T13:26:02Z","updated_at":"2016-08-19T16:27:08Z","pushed_at":"2016-08-21T12:12:48Z","git_url":"git://github.com/xulaus/mr_bump.git","ssh_url":"git@github.com:xulaus/mr_bump.git","clone_url":"https://github.com/xulaus/mr_bump.git","svn_url":"https://github.com/xulaus/mr_bump","homepage":null,"size":37,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"xulaus:master","ref":"master","sha":"e80e9ae2bfa37fec20ae1c220330fffcab89914a","user":{"login":"xulaus","id":9027149,"avatar_url":"https://avatars.githubusercontent.com/u/9027149?v=3","gravatar_id":"","url":"https://api.github.com/users/xulaus","html_url":"https://github.com/xulaus","followers_url":"https://api.github.com/users/xulaus/followers","following_url":"https://api.github.com/users/xulaus/following{/other_user}","gists_url":"https://api.github.com/users/xulaus/gists{/gist_id}","starred_url":"https://api.github.com/users/xulaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xulaus/subscriptions","organizations_url":"https://api.github.com/users/xulaus/orgs","repos_url":"https://api.github.com/users/xulaus/repos","events_url":"https://api.github.com/users/xulaus/events{/privacy}","received_events_url":"https://api.github.com/users/xulaus/received_events","type":"User","site_admin":false},"repo":{"id":65999244,"name":"mr_bump","full_name":"xulaus/mr_bump","owner":{"login":"xulaus","id":9027149,"avatar_url":"https://avatars.githubusercontent.com/u/9027149?v=3","gravatar_id":"","url":"https://api.github.com/users/xulaus","html_url":"https://github.com/xulaus","followers_url":"https://api.github.com/users/xulaus/followers","following_url":"https://api.github.com/users/xulaus/following{/other_user}","gists_url":"https://api.github.com/users/xulaus/gists{/gist_id}","starred_url":"https://api.github.com/users/xulaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xulaus/subscriptions","organizations_url":"https://api.github.com/users/xulaus/orgs","repos_url":"https://api.github.com/users/xulaus/repos","events_url":"https://api.github.com/users/xulaus/events{/privacy}","received_events_url":"https://api.github.com/users/xulaus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xulaus/mr_bump","description":"Tool for versioning git flow projects","fork":false,"url":"https://api.github.com/repos/xulaus/mr_bump","forks_url":"https://api.github.com/repos/xulaus/mr_bump/forks","keys_url":"https://api.github.com/repos/xulaus/mr_bump/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xulaus/mr_bump/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xulaus/mr_bump/teams","hooks_url":"https://api.github.com/repos/xulaus/mr_bump/hooks","issue_events_url":"https://api.github.com/repos/xulaus/mr_bump/issues/events{/number}","events_url":"https://api.github.com/repos/xulaus/mr_bump/events","assignees_url":"https://api.github.com/repos/xulaus/mr_bump/assignees{/user}","branches_url":"https://api.github.com/repos/xulaus/mr_bump/branches{/branch}","tags_url":"https://api.github.com/repos/xulaus/mr_bump/tags","blobs_url":"https://api.github.com/repos/xulaus/mr_bump/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xulaus/mr_bump/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xulaus/mr_bump/git/refs{/sha}","trees_url":"https://api.github.com/repos/xulaus/mr_bump/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xulaus/mr_bump/statuses/{sha}","languages_url":"https://api.github.com/repos/xulaus/mr_bump/languages","stargazers_url":"https://api.github.com/repos/xulaus/mr_bump/stargazers","contributors_url":"https://api.github.com/repos/xulaus/mr_bump/contributors","subscribers_url":"https://api.github.com/repos/xulaus/mr_bump/subscribers","subscription_url":"https://api.github.com/repos/xulaus/mr_bump/subscription","commits_url":"https://api.github.com/repos/xulaus/mr_bump/commits{/sha}","git_commits_url":"https://api.github.com/repos/xulaus/mr_bump/git/commits{/sha}","comments_url":"https://api.github.com/repos/xulaus/mr_bump/comments{/number}","issue_comment_url":"https://api.github.com/repos/xulaus/mr_bump/issues/comments{/number}","contents_url":"https://api.github.com/repos/xulaus/mr_bump/contents/{+path}","compare_url":"https://api.github.com/repos/xulaus/mr_bump/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xulaus/mr_bump/merges","archive_url":"https://api.github.com/repos/xulaus/mr_bump/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xulaus/mr_bump/downloads","issues_url":"https://api.github.com/repos/xulaus/mr_bump/issues{/number}","pulls_url":"https://api.github.com/repos/xulaus/mr_bump/pulls{/number}","milestones_url":"https://api.github.com/repos/xulaus/mr_bump/milestones{/number}","notifications_url":"https://api.github.com/repos/xulaus/mr_bump/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xulaus/mr_bump/labels{/name}","releases_url":"https://api.github.com/repos/xulaus/mr_bump/releases{/id}","deployments_url":"https://api.github.com/repos/xulaus/mr_bump/deployments","created_at":"2016-08-18T13:26:02Z","updated_at":"2016-08-19T16:27:08Z","pushed_at":"2016-08-21T12:12:48Z","git_url":"git://github.com/xulaus/mr_bump.git","ssh_url":"git@github.com:xulaus/mr_bump.git","clone_url":"https://github.com/xulaus/mr_bump.git","svn_url":"https://github.com/xulaus/mr_bump","homepage":null,"size":37,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xulaus/mr_bump/pulls/5"},"html":{"href":"https://github.com/xulaus/mr_bump/pull/5"},"issue":{"href":"https://api.github.com/repos/xulaus/mr_bump/issues/5"},"comments":{"href":"https://api.github.com/repos/xulaus/mr_bump/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/xulaus/mr_bump/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/xulaus/mr_bump/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xulaus/mr_bump/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/xulaus/mr_bump/statuses/e4792cbe601f04b5838ae5a81aabb129f841e4a9"}}}}
{"actor":{"display_login":"jbryant92"}}