github.com/getgauge/gauge@v1.6.9/build/create_release_text.rb (about) 1 # ---------------------------------------------------------------- 2 # Copyright (c) ThoughtWorks, Inc. 3 # Licensed under the Apache License, Version 2.0 4 # See LICENSE.txt in the project root for license information. 5 # ---------------------------------------------------------------- 6 7 require 'net/http' 8 require 'uri' 9 require 'json' 10 11 if ARGV.length < 1 12 puts 'Usage: ruby create_release_text.rb <owner> <name> 13 Example: ruby create_release_text.rb getgauge gauge 14 ' 15 exit 1 16 end 17 18 repo = "#{ARGV[0]}/#{ARGV[1]}" 19 20 api = "https://api.github.com" 21 22 latest_release = URI.join(api, "/repos/#{repo}/releases/latest") 23 timestamp = JSON.parse(Net::HTTP.get(latest_release))['published_at'] 24 25 issues_query = "/search/issues?q=is:pr+repo:#{repo}+is:merged+closed" 26 27 if not timestamp.nil? || timestamp.empty? 28 issues_query += ":>#{timestamp}" 29 end 30 31 uri = URI.join(api, issues_query) 32 req = Net::HTTP::Get.new(uri) 33 req['Accept'] = "application/vnd.github.v3.full+json" 34 http = Net::HTTP.new(uri.hostname, uri.port) 35 http.use_ssl = true 36 response = http.request(req) 37 38 case response 39 when Net::HTTPSuccess 40 issues = JSON.parse(response.body) 41 42 issues['items'].each do |issue| 43 puts "- ##{issue['number']} - #{issue['title']}" 44 end 45 46 else 47 raise " 48 Could not fetch release information for github repo: 49 50 https://github.com/#{repo} 51 52 Please check if this is a valid repo." 53 end