Created
December 26, 2018 11:25
-
-
Save masatomo/c3eb38609740887217cc3636a1375bcc to your computer and use it in GitHub Desktop.
issue2markdown.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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