Skip to content

Instantly share code, notes, and snippets.

@masatomo
Created December 26, 2018 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masatomo/c3eb38609740887217cc3636a1375bcc to your computer and use it in GitHub Desktop.
Save masatomo/c3eb38609740887217cc3636a1375bcc to your computer and use it in GitHub Desktop.
issue2markdown.rb
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem "octokit", "~> 4.0"
end
url = ARGV[0]
unless url
puts "Usage: issue2markdown.rb <issue url>"
puts ""
puts "example usage: "
puts "* $ GITHUB_ACCESS_TOKEN=<token> ./issue2markdown.rb https://github.com/quipper/quipper/issues/11111 | pbcopy"
puts "* paste it in wiki and edit it."
puts ""
exit 1
end
access_token = ENV['GITHUB_ACCESS_TOKEN'] || raise('GitHub access token is not found')
_, repo, number = matches = /^http.*\/\/github.com\/(.+)\/issues\/([0-9]+)/.match(url).to_a
if !repo || !number
puts "Error: #{url} is not correct url for a github issue"
exit 1
end
client = Octokit::Client.new(access_token: access_token,
auto_paginate: true)
issue = client.issue(repo, number)
puts "# #{issue.title}"
puts ""
puts issue.body
puts ""
comments = client.issue_comments(repo, number)
comments.each do |comment|
puts comment.body
puts ""
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment