|
| 1 | +#!/usr/bin/env ruby |
| 2 | + |
| 3 | +require 'octokit' |
| 4 | + |
| 5 | +date_since = ARGV.first |
| 6 | + |
| 7 | +if date_since.nil? or date_since.empty? |
| 8 | + puts "Usage: deis-contributions-since <yyyy-mm-dd>" |
| 9 | + exit 1 |
| 10 | +end |
| 11 | + |
| 12 | +# ignore project maintainers |
| 13 | +ignored_contributors = %w[bacongobbler carmstrong gabrtv mboersma] |
| 14 | + |
| 15 | +# make our GitHub calls here |
| 16 | +client = Octokit::Client.new(:access_token => ENV['GITHUB_ACCESS_TOKEN']) |
| 17 | +prs_obj = client.search_issues("repo:deis/deis is:pr is:merged merged:>#{date_since}", {:sort => 'updated', :order => 'desc', :per_page => 1000}) |
| 18 | +issues_obj = client.search_issues("repo:deis/deis is:issue created:>#{date_since}", {:per_page => 1000}) |
| 19 | + |
| 20 | +contributors = {} |
| 21 | + |
| 22 | +puts "-----" |
| 23 | +puts "Found #{issues_obj.items.size} issues opened on or after #{date_since}" |
| 24 | +puts "Found #{prs_obj.items.count} pull requests merged on or after #{date_since}" |
| 25 | +puts "-----" |
| 26 | +puts |
| 27 | + |
| 28 | +issues_obj.items.each do |issue| |
| 29 | + author = issue.user.login.to_s |
| 30 | + title = issue.title.to_s |
| 31 | + if contributors[author].nil? |
| 32 | + contributors[author] = [title] |
| 33 | + else |
| 34 | + contributors[author].push(title) |
| 35 | + end |
| 36 | +end |
| 37 | + |
| 38 | +prs_obj.items.each do |pr| |
| 39 | + author = pr.user.login.to_s |
| 40 | + title = pr.title.to_s |
| 41 | + if contributors[author].nil? |
| 42 | + contributors[author] = [title] |
| 43 | + else |
| 44 | + contributors[author].push(title) |
| 45 | + end |
| 46 | + puts "- #{pr.title} - [\##{pr.number}](#{pr.pull_request.html_url}) ([@#{pr.user.login}](#{pr.user.html_url}))" |
| 47 | +end |
| 48 | +puts |
| 49 | + |
| 50 | +# remove project maintainers from the list of contributors |
| 51 | +contributors.reject! {|k,v| ignored_contributors.include?(k) } |
| 52 | + |
| 53 | +puts '### Community Shout-Outs' |
| 54 | +puts |
| 55 | +puts 'We want to thank the following Deis community members for creating GitHub issues, |
| 56 | +providing support to others, and working on various Deis branches:' |
| 57 | +puts |
| 58 | +contributors.sort_by {|k,v| k.downcase}.map do |author, titles| |
| 59 | + puts "@#{author}: #{titles.join(", ")}" |
| 60 | +end |
| 61 | +puts |
| 62 | +puts "The Deis community continues to grow, and Deis wouldn't be here without you! If we slighted your contribution to this release, please let us know so we can update." |
| 63 | +puts |
0 commit comments