changelogerator 0.0.5 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/changelogerator.rb +33 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cc3a9284da3838260c00f82dd7244af8adabfaaa26627f6eb0fa036f3d8947a
4
- data.tar.gz: 0d5573d1f76b165e0bdf6c32d6e570c35559656c036d894cfbfa1fb2f7624a49
3
+ metadata.gz: 400a2661d78f9c51ff0a2c4dacc852d464a9997f29c8017df1f5d585318504ff
4
+ data.tar.gz: 1c32b784170d2eb50a1edea3aaee8e2b3d30321c5539209606913ea788ece2a3
5
5
  SHA512:
6
- metadata.gz: b6011c4fcecabb729edb5dcffdfb9150ac0ee426f9d34ca6504f6cd6d6e392ac661d4108dfb1f154cf82e5fcba7eed94422f2563e8c856c8a99be83bdb3875bd
7
- data.tar.gz: d79877222a2ab0b6982f7d1addc9c5545ae79e2e888907350b8efa1b0a46a776e6e61768df42e58dc1435ef3a11694e38e1debe88f9a77a5151ced3f47c153c2
6
+ metadata.gz: 538053876b3075cf839b80812a108854ff54a172683bd4c155cc7f4e17d52b6036746817742c0b956744a91861af870466a9873bba11db11866bacfb2086810f
7
+ data.tar.gz: 79dd9b05c967834aa77b76ef08a83f0eccaaae33364743eb1512c2992ef49ab128dacae9c3303c85e647ed5126a62818ed66d633338eaedb889d5a424f51675c
@@ -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.8
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: 2020-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git_diff_parser