changelogerator 0.0.5 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/changelogerator.rb +33 -13
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cc3a9284da3838260c00f82dd7244af8adabfaaa26627f6eb0fa036f3d8947a
4
- data.tar.gz: 0d5573d1f76b165e0bdf6c32d6e570c35559656c036d894cfbfa1fb2f7624a49
3
+ metadata.gz: 2e49b291908975f2e1e1ae6423ddbcff58d7b675f4faeaff1da0e7e9f507c2e9
4
+ data.tar.gz: 5f6b04cbbfeefa08c5ec8a009e33e375e1181d98d4b4c6c6ed5ca12e746d09b9
5
5
  SHA512:
6
- metadata.gz: b6011c4fcecabb729edb5dcffdfb9150ac0ee426f9d34ca6504f6cd6d6e392ac661d4108dfb1f154cf82e5fcba7eed94422f2563e8c856c8a99be83bdb3875bd
7
- data.tar.gz: d79877222a2ab0b6982f7d1addc9c5545ae79e2e888907350b8efa1b0a46a776e6e61768df42e58dc1435ef3a11694e38e1debe88f9a77a5151ced3f47c153c2
6
+ metadata.gz: 325899dc82529c7ac01ec2fac27f4afbfe6947d1b5d4a04325b09b2844034ef261a11e8d5aa0be6c01a72416325234f6749ae88f8c7a98ed811c2c06bc532c63
7
+ data.tar.gz: 2fc93ea4292287bc9a01c36bd858e7d2afd960007e90edf4457c878a37fdf016c80a1c55dde80e3660d1297a646fbb7a70b695c4adda5488164ea2d793cddbb6
@@ -80,7 +80,8 @@ class Changelog
80
80
  @gh = Octokit::Client.new(
81
81
  access_token: token
82
82
  )
83
- @changes = prs_from_ids(pr_ids_from_git_diff(from, to), prefix)
83
+ @prefix = prefix
84
+ @changes = prs_from_ids(pr_ids_from_git_diff(from, to))
84
85
  # add priority to each change
85
86
  @changes.map { |c| apply_priority_to_change(c) }
86
87
  end
@@ -90,10 +91,18 @@ class Changelog
90
91
  end
91
92
 
92
93
  def runtime_changes?
93
-
94
94
  nil
95
95
  end
96
96
 
97
+ def add(change)
98
+ changes.prepend(apply_priority_to_change(change))
99
+ end
100
+
101
+ def add_from_id(id)
102
+ pull = @gh.pull_request(@repo, id)
103
+ add(prettify_title(pull))
104
+ end
105
+
97
106
  private
98
107
 
99
108
  def apply_priority_to_change(change)
@@ -103,26 +112,37 @@ class Changelog
103
112
  change
104
113
  end
105
114
 
115
+ def prettify_title(pull)
116
+ pull[:pretty_title] = if @prefix
117
+ "#{pull[:title]} (#{@repo}##{pull[:number]})"
118
+ else
119
+ "#{pull[:title]} (##{pull[:number]})"
120
+ end
121
+ pull
122
+ end
123
+
106
124
  def pr_ids_from_git_diff(from, to)
107
125
  @gh.compare(@repo, from, to).commits.map do |c|
108
126
  title = c.commit.message.split("\n\n").first
109
127
  next unless title =~ /\(#[0-9]+\)$/
110
128
 
111
129
  title.gsub(/.*#([0-9]+)\)$/, '\1')
112
- end.compact
130
+ end.compact.map(&:to_i)
113
131
  end
114
132
 
115
- def prs_from_ids(ids, prefix)
133
+ def prs_from_ids(ids)
134
+ batch_size = 100
116
135
  prs = []
117
- ids.each do |pr|
118
- pull = @gh.pull_request(@repo, pr)
119
- pull[:pretty_title] = if prefix
120
- "#{pull[:title]} (#{@repo}##{pull[:number]})"
121
- else
122
- "#{pull[:title]} (##{pull[:number]})"
123
- end
124
- prs.push pull
136
+ @gh.pulls(@repo, state: 'closed', per_page: batch_size)
137
+ cur_batch = @gh.last_response
138
+ until ids.empty?
139
+ prs += cur_batch.data.select { |pr| ids.include? pr.number }
140
+ ids -= cur_batch.data.map(&:number)
141
+ break if cur_batch.rels[:last].nil?
142
+
143
+ cur_batch = cur_batch.rels[:next].get
125
144
  end
126
- prs
145
+ prs.flatten
146
+ prs.map { |pr| prettify_title(pr) }
127
147
  end
128
148
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: changelogerator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Pugh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-21 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git_diff_parser
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  requirements: []
67
- rubygems_version: 3.0.3
67
+ rubygems_version: 3.2.7
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: Changelog generation/management