Skip to content

Commit 02b0f95

Browse files
committed
Merge branch 'release/1.3.5'
2 parents af189dc + c20529b commit 02b0f95

File tree

5 files changed

+57
-76
lines changed

5 files changed

+57
-76
lines changed

CHANGELOG.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
**Closed issues:**
1616

17-
- Add \# character to wrapping list. [\#58](https://github.com/skywinder/Github-Changelog-Generator/issues/58)
17+
- Add \# character to encapsulate list. [\#58](https://github.com/skywinder/Github-Changelog-Generator/issues/58)
1818

1919
## [1.3.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.2) (2015-03-03)
2020

@@ -108,10 +108,6 @@
108108

109109
- Crash when try generate log for rails [\#35](https://github.com/skywinder/Github-Changelog-Generator/issues/35)
110110

111-
**Merged pull requests:**
112-
113-
- Implement async fetching [\#39](https://github.com/skywinder/Github-Changelog-Generator/pull/39) ([skywinder](https://github.com/skywinder))
114-
115111
## [1.2.3](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.3) (2014-12-16)
116112

117113
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.2...1.2.3)
@@ -128,6 +124,8 @@
128124

129125
**Merged pull requests:**
130126

127+
- Implement async fetching [\#39](https://github.com/skywinder/Github-Changelog-Generator/pull/39) ([skywinder](https://github.com/skywinder))
128+
131129
- Fix crash when user is NULL [\#40](https://github.com/skywinder/Github-Changelog-Generator/pull/40) ([skywinder](https://github.com/skywinder))
132130

133131
## [1.2.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.2) (2014-12-10)
@@ -220,10 +218,6 @@
220218

221219
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.0.0...1.0.1)
222220

223-
**Merged pull requests:**
224-
225-
- Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8) ([skywinder](https://github.com/skywinder))
226-
227221
## [1.0.0](https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.0) (2014-11-07)
228222

229223
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.1.0...1.0.0)
@@ -240,16 +234,18 @@
240234

241235
**Merged pull requests:**
242236

243-
- Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7) ([skywinder](https://github.com/skywinder))
237+
- Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8) ([skywinder](https://github.com/skywinder))
244238

245-
- Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3) ([skywinder](https://github.com/skywinder))
239+
- Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7) ([skywinder](https://github.com/skywinder))
246240

247241
## [0.1.0](https://github.com/skywinder/Github-Changelog-Generator/tree/0.1.0) (2014-11-07)
248242

249243
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.0.2...0.1.0)
250244

251245
**Merged pull requests:**
252246

247+
- Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3) ([skywinder](https://github.com/skywinder))
248+
253249
- Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2) ([skywinder](https://github.com/skywinder))
254250

255251
- Add option \(-o --output\) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1) ([skywinder](https://github.com/skywinder))

lib/CHANGELOG.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
# Change Log
22

3-
## [Unreleased](https://github.com/nantas/changelog_test/tree/HEAD) (2015-03-03)
3+
## [v0.0.3](https://github.com/skywinder/changelog_test/tree/v0.0.3) (2015-03-04)
44

5-
[Full Changelog](https://github.com/nantas/changelog_test/compare/v0.0.1...HEAD)
5+
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.2...v0.0.3)
66

7-
**Fixed bugs:**
7+
**Merged pull requests:**
88

9-
- test issue closed by a commit that will be gone [\#3](https://github.com/nantas/changelog_test/issues/3)
9+
- fix \#3. hotfix. Should appear in v0.0.3 [\#4](https://github.com/skywinder/changelog_test/pull/4) ([skywinder](https://github.com/skywinder))
1010

11-
**Closed issues:**
11+
## [v0.0.2](https://github.com/skywinder/changelog_test/tree/v0.0.2) (2015-03-04)
1212

13-
- test issue that will be closed in another repo [\#4](https://github.com/nantas/changelog_test/issues/4)
13+
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.1...v0.0.2)
1414

15-
## [v0.0.1](https://github.com/nantas/changelog_test/tree/v0.0.1) (2015-03-02)
15+
**Merged pull requests:**
1616

17-
**Fixed bugs:**
17+
- Here is a test hotfix should appear in v.0.0.2 [\#2](https://github.com/skywinder/changelog_test/pull/2) ([skywinder](https://github.com/skywinder))
1818

19-
- test issue that will be closed by a commit [\#2](https://github.com/nantas/changelog_test/issues/2)
20-
21-
- test issue that will close normally [\#1](https://github.com/nantas/changelog_test/issues/1)
19+
## [v0.0.1](https://github.com/skywinder/changelog_test/tree/v0.0.1) (2015-03-02)
2220

2321

2422

lib/github_changelog_generator.rb

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ def initialize
4949

5050
if @options[:issues]
5151
@issues = self.get_filtered_issues
52-
fetch_event_for_issues(@issues)
53-
detect_actual_closed_dates
5452
else
5553
@issues = []
5654
end
5755

56+
fetch_event_for_issues_and_pr
57+
detect_actual_closed_dates
5858
@tag_times_hash = {}
5959
end
6060

@@ -65,11 +65,18 @@ def detect_actual_closed_dates
6565
end
6666

6767
threads = []
68+
6869
@issues.each { |issue|
6970
threads << Thread.new {
7071
find_closed_date_by_commit(issue)
7172
}
7273
}
74+
75+
@pull_requests.each { |pull_request|
76+
threads << Thread.new {
77+
find_closed_date_by_commit(pull_request)
78+
}
79+
}
7380
threads.each { |thr| thr.join }
7481

7582
if @options[:verbose]
@@ -79,9 +86,11 @@ def detect_actual_closed_dates
7986

8087
def find_closed_date_by_commit(issue)
8188
unless issue['events'].nil?
89+
#if it's PR -> then find "merged event", in case of usual issue -> fond closed date
90+
compare_string = issue[:merged_at].nil? ? 'closed' : 'merged'
8291
# reverse! - to find latest closed event. (event goes in date order)
8392
issue['events'].reverse!.each { |event|
84-
if event[:event].eql? 'closed'
93+
if event[:event].eql? compare_string
8594
if event[:commit_id].nil?
8695
issue[:actual_date] = issue[:closed_at]
8796
else
@@ -111,7 +120,7 @@ def exec_command(cmd)
111120

112121
def fetch_merged_at_pull_requests
113122
if @options[:verbose]
114-
print "Fetching pull requests...\r"
123+
print "Fetching merged dates...\r"
115124
end
116125
response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed'
117126

@@ -120,21 +129,22 @@ def fetch_merged_at_pull_requests
120129
response.each_page do |page|
121130
page_i += PER_PAGE_NUMBER
122131
count_pages = response.count_pages
123-
print "Fetching pull requests... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
132+
print "Fetching merged dates... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
124133
pull_requests.concat(page)
125134
end
126135
print " \r"
127136

128-
if @options[:verbose]
129-
puts "Received pull requests: #{pull_requests.count}"
130-
end
131-
132137
@pull_requests.each { |pr|
133138
fetched_pr = pull_requests.find { |fpr|
134139
fpr.number == pr.number }
135140
pr[:merged_at] = fetched_pr[:merged_at]
136141
pull_requests.delete(fetched_pr)
137142
}
143+
144+
if @options[:verbose]
145+
puts 'Fetching merged dates... Done!'
146+
end
147+
138148
end
139149

140150
def get_filtered_pull_requests
@@ -171,43 +181,6 @@ def get_filtered_pull_requests
171181
end
172182

173183
filtered_pull_requests
174-
#
175-
# #
176-
#
177-
#
178-
# unless @options[:pull_request_labels].nil?
179-
#
180-
# if @options[:verbose]
181-
# puts 'Filter all pull requests by labels.'
182-
# end
183-
#
184-
# filtered_pull_requests = filtered_pull_requests.select { |pull_request|
185-
# #fetch this issue to get labels array
186-
# issue = @github.issues.get @options[:user], @options[:project], pull_request.number
187-
#
188-
# #compare is there any labels from @options[:labels] array
189-
# issue_without_labels = !issue.labels.map { |label| label.name }.any?
190-
#
191-
# if @options[:verbose]
192-
# puts "Filter request \##{issue.number}."
193-
# end
194-
#
195-
# if @options[:pull_request_labels].any?
196-
# select_by_label = (issue.labels.map { |label| label.name } & @options[:pull_request_labels]).any?
197-
# else
198-
# select_by_label = false
199-
# end
200-
#
201-
# select_by_label | issue_without_labels
202-
# }
203-
#
204-
# if @options[:verbose]
205-
# puts "Filtered pull requests with specified labels and w/o labels: #{filtered_pull_requests.count}"
206-
# end
207-
# return filtered_pull_requests
208-
# end
209-
#
210-
# filtered_pull_requests
211184
end
212185

213186
def compund_changelog
@@ -359,7 +332,7 @@ def github_token
359332

360333
def generate_log_between_tags(older_tag, newer_tag)
361334
# older_tag nil - means it's first tag, newer_tag nil - means it unreleased section
362-
filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, older_tag, newer_tag)
335+
filtered_pull_requests = delete_by_time(@pull_requests, :actual_date, older_tag, newer_tag)
363336
filtered_issues = delete_by_time(@issues, :actual_date, older_tag, newer_tag)
364337

365338
newer_tag_name = newer_tag.nil? ? nil : newer_tag['name']
@@ -628,27 +601,41 @@ def fetch_issues_and_pull_requests
628601
return issues_wo_pr, pull_requests
629602
end
630603

631-
def fetch_event_for_issues(filtered_issues)
604+
def fetch_event_for_issues_and_pr
632605
if @options[:verbose]
633-
print "Fetching events for issues: 0/#{filtered_issues.count}\r"
606+
print "Fetching events for issues and PR: 0/#{@issues.count + @pull_requests.count}\r"
634607
end
635608

636609
# Async fetching events:
637610
threads = []
638611

639612
i = 0
640-
filtered_issues.each { |issue|
613+
614+
@issues.each { |issue|
641615
threads << Thread.new {
642616
obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: issue['number']
643617
issue[:events] = obj.body
644-
print "Fetching events for issues: #{i+1}/#{filtered_issues.count}\r"
618+
print "Fetching events for issues and PR: #{i+1}/#{@issues.count + @pull_requests.count}\r"
619+
i +=1
620+
}
621+
}
622+
623+
@pull_requests.each { |pull_request|
624+
threads << Thread.new {
625+
obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: pull_request['number']
626+
pull_request[:events] = obj.body
627+
print "Fetching events for issues and PR: #{i+1}/#{@issues.count + @pull_requests.count}\r"
645628
i +=1
646629
}
647630
}
631+
648632
threads.each { |thr| thr.join }
649633

634+
#to clear line from prev print
635+
print " \r"
636+
650637
if @options[:verbose]
651-
puts "Fetching events for issues: Done!"
638+
puts "Fetching events for issues and PR: Done! #{i}/#{@issues.count + @pull_requests.count}"
652639
end
653640
end
654641

lib/github_changelog_generator/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def self.parse_options
3131
options = hash
3232

3333
parser = OptionParser.new { |opts|
34-
opts.banner = 'Usage: changelog_generator [options]'
34+
opts.banner = 'Usage: github_changelog_generator [options]'
3535
opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo') do |last|
3636
options[:user] = last
3737
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module GitHubChangelogGenerator
2-
VERSION = '1.3.4'
2+
VERSION = '1.3.5'
33
end

0 commit comments

Comments
 (0)