-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathslackmsg
More file actions
executable file
·32 lines (28 loc) · 786 Bytes
/
slackmsg
File metadata and controls
executable file
·32 lines (28 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/ruby
require 'json'
jira_id = ARGV[0]
if jira_id.nil?
puts "Trying to get JIRA ID from git branch name"
jira_id = `git rev-parse --abbrev-ref HEAD`.strip
if !jira_id.start_with?("NA")
STDERR.puts "Invalid JIRA ID? #{jira_id}"
exit 1
end
end
if jira_id.nil?
STDERR.puts "Unable to get JIRA ID"
exit 1
end
jira_url = 'https://jiradrdk.atlassian.net/browse/' + jira_id
puts "Fetching PR URL"
pull_request_url = JSON.parse(`gh pr view --json url`.strip)['url']
if pull_request_url.nil?
STDERR.puts "Unable to get pull request url"
exit 1
end
msg = "[#{jira_id}](#{jira_url}) \n[PR](#{pull_request_url})"
puts "==================================="
puts msg
puts "==================================="
puts "Copied to clipboard"
`echo "#{msg}" | pbcopy`