github_fast_changelog 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 904580ecd6a45560a9906a3bbbb8f545e1137995611ec1610fed62a5cf97aa93
4
+ data.tar.gz: c54b2ba68b4030e25906dae4ad4525739fa6ec8d5502eeb0fa1c7c1d4d11b97e
5
+ SHA512:
6
+ metadata.gz: '09f3ca3944d2cc3ee14d65d40ff3d813c941485705fb4eec55e4251acd7661ee94818c51aced13db1153d608d3bf49ab9049be5129f406faf9855c609da94f96'
7
+ data.tar.gz: f0f05ec02fdc44df3f82e7184cdf3e022de71b3a2d8f9e14b1c2e27de5420be739d61fc7fe9eaa7067da125b060b4ad94d31bab4303357ed3d9d7fe6671adf6d
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at john@hawthorn.email. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in github_fast_changelog.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 John Hawthorn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ # GithubFastChangelog
2
+
3
+ Uses GitHub's v4 GraphQL API to generate a CHANGELOG from PRs matching a list of commits.
4
+
5
+ I used to use [GitHub Changelog
6
+ Generator](https://github.com/github-changelog-generator/github-changelog-generator)
7
+ (which is a better and way more complete project), but the project I worked on
8
+ was too large (several thousand PRs) and always hit github's rate limit.
9
+
10
+ This project uses GitHub's v4 GraphQL API to query the PRs very efficiently and shouldn't ever hit the rate limit
11
+
12
+ ## Installation
13
+
14
+ $ gem install github_fast_changelog
15
+
16
+ ## Usage
17
+
18
+ This expects a list of commits (some of which should match the merge commit of a PR) on STDIN. Writes markdown to STDOUT.
19
+
20
+ $ export GITHUB_ACCESS_TOKEN=....
21
+ $ git rev-list v2.4...v2.5 | github_fast_changelog example/github_repo > CHANGELOG.md
22
+
23
+
24
+ Output is:
25
+
26
+ ```
27
+ - Add usage instructions to README [#1](https://github.com/jhawthorn/github_fast_changelog/pull/1) ([jhawthorn](https://github.com/jhawthorn))
28
+ ```
29
+
30
+ Rendered:
31
+
32
+ - Add usage instructions to README [#1](https://github.com/jhawthorn/github_fast_changelog/pull/1) ([jhawthorn](https://github.com/jhawthorn))
33
+
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jhawthorn/github_fast_changelog. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
+
49
+ ## Code of Conduct
50
+
51
+ Everyone interacting in the GithubFastChangelog project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jhawthorn/github_fast_changelog/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "github_fast_changelog"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ def usage
4
+ $stderr.puts "Usage: git rev-list v2.4...v2.5 | #$0 example/github_repo > CHANGELOG.md"
5
+ exit 1
6
+ end
7
+
8
+ if ARGV.length != 1 || /[-_\w]+\/[-_.\w]+/ !~ ARGV[0] || $stdin.isatty
9
+ usage
10
+ end
11
+
12
+ commits = $stdin.read.split
13
+
14
+ if commits.empty?
15
+ usage
16
+ end
17
+
18
+ output = $stdout
19
+ logger = output.isatty ? File.open(File::NULL, "w") : $stderr
20
+
21
+ project = ARGV[0]
22
+ owner, name = project.split('/', 2)
23
+
24
+ def format_pull(pull)
25
+ <<~MD
26
+ - #{pull.title} [\##{pull.number}](#{pull.url}) ([#{pull.author.login}](#{pull.author.url}))
27
+ MD
28
+ end
29
+
30
+ require 'github_fast_changelog'
31
+
32
+ logger.puts "Generating changelog"
33
+ GithubFastChangelog.each_pull_request(owner: owner, name: name) do |pull|
34
+ in_release = pull.merge_commit && commits.include?(pull.merge_commit.oid)
35
+ if in_release
36
+ md = format_pull(pull)
37
+ output.puts(md)
38
+ logger << "#"
39
+ else
40
+ logger << "."
41
+ end
42
+ logger.flush
43
+ end
44
+ logger.puts ""
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "github_fast_changelog/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "github_fast_changelog"
8
+ spec.version = GithubFastChangelog::VERSION
9
+ spec.authors = ["John Hawthorn"]
10
+ spec.email = ["john@hawthorn.email"]
11
+
12
+ spec.summary = %q{Generates a CHANGELOG based on GitHub PRs}
13
+ spec.description = %q{Uses GitHub's v4 GraphQL API to generate a CHANGELOG from PRs matching a list of commits}
14
+ spec.homepage = "https://github.com/jhawthorn/github_fast_changelog"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "graphql", "~> 1.6"
25
+ spec.add_dependency "graphql-client"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "minitest", "~> 5.0"
30
+ end
@@ -0,0 +1,70 @@
1
+ require 'graphql/client'
2
+ require 'graphql/client/http'
3
+
4
+ require "github_fast_changelog/version"
5
+
6
+ module GithubFastChangelog
7
+ HTTP = GraphQL::Client::HTTP.new("https://api.github.com/graphql") do
8
+ def headers(context)
9
+ if token = ENV['GITHUB_ACCESS_TOKEN']
10
+ { "Authorization" => "Bearer #{token}" }
11
+ else
12
+ fail "Missing ENV GITHUB_ACCESS_TOKEN"
13
+ end
14
+ end
15
+ end
16
+ Schema = GraphQL::Client.load_schema(HTTP)
17
+ Client = GraphQL::Client.new(schema: Schema, execute: HTTP)
18
+
19
+ MergedPullsQuery = Client.parse <<-GRAPHQL
20
+ query($before: String, $owner: String!, $name: String!) {
21
+ repository(owner: $owner, name: $name) {
22
+ name
23
+ pullRequests(last:100, before: $before, states:MERGED) {
24
+ pageInfo {
25
+ endCursor
26
+ hasNextPage
27
+ hasPreviousPage
28
+ startCursor
29
+ }
30
+ edges {
31
+ node {
32
+ id
33
+ number
34
+ title
35
+ url
36
+ author {
37
+ login
38
+ url
39
+ }
40
+ mergedAt
41
+ mergeCommit {
42
+ oid
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ GRAPHQL
50
+
51
+ def self.each_pull_request(owner:, name:)
52
+ cursor = nil
53
+ loop do
54
+ result = Client.query(MergedPullsQuery, variables: {
55
+ before: cursor,
56
+ owner: owner,
57
+ name: name
58
+ })
59
+ data = result.data.repository.pull_requests
60
+ more = data.page_info.has_previous_page
61
+ cursor = data.page_info.start_cursor
62
+
63
+ data.edges.reverse.map do |edge|
64
+ yield edge.node
65
+ end
66
+
67
+ break unless more
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,3 @@
1
+ module GithubFastChangelog
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github_fast_changelog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - John Hawthorn
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: graphql
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: graphql-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ description: Uses GitHub's v4 GraphQL API to generate a CHANGELOG from PRs matching
84
+ a list of commits
85
+ email:
86
+ - john@hawthorn.email
87
+ executables:
88
+ - github_fast_changelog
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".travis.yml"
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - exe/github_fast_changelog
102
+ - github_fast_changelog.gemspec
103
+ - lib/github_fast_changelog.rb
104
+ - lib/github_fast_changelog/version.rb
105
+ homepage: https://github.com/jhawthorn/github_fast_changelog
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.7.6
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Generates a CHANGELOG based on GitHub PRs
129
+ test_files: []