Compare commits

...

24 Commits
1.3.3 ... 1.3.6

Author SHA1 Message Date
Petr Korolev
27fa9e8e02 Merge branch 'hotfix/fix-nil-tag' 2015-03-05 14:35:56 +02:00
Petr Korolev
0706f89c02 Update gemspec to version 1.3.6 2015-03-05 14:35:54 +02:00
Petr Korolev
419e7e78ad Fix: exception in case no tags in repo 2015-03-05 14:33:01 +02:00
Petr Korolev
6159ebba2f refactoring 2015-03-05 13:20:51 +02:00
Petr Korolev
3a200e943c Merge branch 'hotfix/update-changelog' 2015-03-04 21:27:36 +02:00
Petr Korolev
4dc5a094d2 Merge branch 'hotfix/update-changelog' into develop 2015-03-04 21:27:36 +02:00
Petr Korolev
07d52c9465 Update changelog for version 1.3.5 2015-03-04 21:27:34 +02:00
Petr Korolev
02b0f95ab0 Merge branch 'release/1.3.5' 2015-03-04 21:27:05 +02:00
Petr Korolev
0b1f0319db Merge branch 'release/1.3.5' into develop 2015-03-04 21:27:05 +02:00
Petr Korolev
c20529bf32 Update gemspec to version 1.3.5 2015-03-04 21:27:03 +02:00
Petr Korolev
26c393c2cc Fix #60. Thanks, @GeekOnCoffee! 2015-03-04 21:25:21 +02:00
Petr Korolev
f8f887093a update changelog test repo 2015-03-04 19:40:15 +02:00
Petr Korolev
63bf4a59d4 fix help message 2015-03-04 16:45:18 +02:00
Petr Korolev
af189dc66f Merge branch 'hotfix/update-changelog' 2015-03-03 19:20:30 +02:00
Petr Korolev
917041424b Merge branch 'hotfix/update-changelog' into develop 2015-03-03 19:20:30 +02:00
Petr Korolev
2e5099efee Update changelog for version 1.3.4 2015-03-03 19:20:28 +02:00
Petr Korolev
9685d79f61 Merge branch 'hotfix/fix-59' 2015-03-03 19:19:54 +02:00
Petr Korolev
fb6b3dad5b Merge branch 'hotfix/fix-59' into develop 2015-03-03 19:19:54 +02:00
Petr Korolev
8d27718648 Update gemspec to version 1.3.4 2015-03-03 19:19:52 +02:00
Petr Korolev
8f8be4740d fix #59 2015-03-03 19:19:08 +02:00
Petr Korolev
26bd24b7d2 Merge branch 'hotfix/update-changelog' 2015-03-03 17:59:52 +02:00
Petr Korolev
049599a0a4 Merge branch 'hotfix/update-changelog' into develop 2015-03-03 17:59:52 +02:00
Petr Korolev
fcbf661d32 Update changelog for version 1.3.3 2015-03-03 17:59:50 +02:00
Petr Korolev
98cdd685b9 Merge branch 'release/1.3.3' into develop 2015-03-03 17:59:04 +02:00
5 changed files with 86 additions and 117 deletions

View File

@@ -1,12 +1,28 @@
# Change Log
## [Unreleased](https://github.com/skywinder/Github-Changelog-Generator/tree/HEAD)
## [1.3.5](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.5) (2015-03-04)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.2...HEAD)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.4...1.3.5)
**Fixed bugs:**
- Pull Requests in Wrong Tag [\#60](https://github.com/skywinder/Github-Changelog-Generator/issues/60)
## [1.3.4](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.4) (2015-03-03)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.3...1.3.4)
**Fixed bugs:**
- --no-issues appears to break PRs [\#59](https://github.com/skywinder/Github-Changelog-Generator/issues/59)
## [1.3.3](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.3) (2015-03-03)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.3.2...1.3.3)
**Closed issues:**
- Add \# character to wrapping list. [\#58](https://github.com/skywinder/Github-Changelog-Generator/issues/58)
- Add \# character to encapsulate list. [\#58](https://github.com/skywinder/Github-Changelog-Generator/issues/58)
## [1.3.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.3.2) (2015-03-03)
@@ -100,10 +116,6 @@
- Crash when try generate log for rails [\#35](https://github.com/skywinder/Github-Changelog-Generator/issues/35)
**Merged pull requests:**
- Implement async fetching [\#39](https://github.com/skywinder/Github-Changelog-Generator/pull/39) ([skywinder](https://github.com/skywinder))
## [1.2.3](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.3) (2014-12-16)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.2.2...1.2.3)
@@ -120,6 +132,8 @@
**Merged pull requests:**
- Implement async fetching [\#39](https://github.com/skywinder/Github-Changelog-Generator/pull/39) ([skywinder](https://github.com/skywinder))
- Fix crash when user is NULL [\#40](https://github.com/skywinder/Github-Changelog-Generator/pull/40) ([skywinder](https://github.com/skywinder))
## [1.2.2](https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.2) (2014-12-10)
@@ -212,10 +226,6 @@
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/1.0.0...1.0.1)
**Merged pull requests:**
- Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8) ([skywinder](https://github.com/skywinder))
## [1.0.0](https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.0) (2014-11-07)
[Full Changelog](https://github.com/skywinder/Github-Changelog-Generator/compare/0.1.0...1.0.0)
@@ -232,9 +242,9 @@
**Merged pull requests:**
- Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7) ([skywinder](https://github.com/skywinder))
- Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8) ([skywinder](https://github.com/skywinder))
- Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3) ([skywinder](https://github.com/skywinder))
- Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7) ([skywinder](https://github.com/skywinder))
## [0.1.0](https://github.com/skywinder/Github-Changelog-Generator/tree/0.1.0) (2014-11-07)
@@ -242,6 +252,8 @@
**Merged pull requests:**
- Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3) ([skywinder](https://github.com/skywinder))
- Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2) ([skywinder](https://github.com/skywinder))
- 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))

View File

@@ -1,25 +1,5 @@
# Change Log
## [Unreleased](https://github.com/nantas/changelog_test/tree/HEAD) (2015-03-03)
[Full Changelog](https://github.com/nantas/changelog_test/compare/v0.0.1...HEAD)
**Fixed bugs:**
- test issue closed by a commit that will be gone [\#3](https://github.com/nantas/changelog_test/issues/3)
**Closed issues:**
- test issue that will be closed in another repo [\#4](https://github.com/nantas/changelog_test/issues/4)
## [v0.0.1](https://github.com/nantas/changelog_test/tree/v0.0.1) (2015-03-02)
**Fixed bugs:**
- test issue that will be closed by a commit [\#2](https://github.com/nantas/changelog_test/issues/2)
- test issue that will close normally [\#1](https://github.com/nantas/changelog_test/issues/1)
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

View File

@@ -20,13 +20,7 @@ module GitHubChangelogGenerator
@options = Parser.parse_options
if options[:verbose]
puts 'Input options:'
pp options
puts ''
end
github_token
fetch_github_token
github_options = {per_page: PER_PAGE_NUMBER}
github_options[:oauth_token] = @github_token unless @github_token.nil?
@@ -49,12 +43,12 @@ module GitHubChangelogGenerator
if @options[:issues]
@issues = self.get_filtered_issues
fetch_event_for_issues(@issues)
detect_actual_closed_dates
else
@issues = []
end
fetch_event_for_issues_and_pr
detect_actual_closed_dates
@tag_times_hash = {}
end
@@ -65,11 +59,18 @@ module GitHubChangelogGenerator
end
threads = []
@issues.each { |issue|
threads << Thread.new {
find_closed_date_by_commit(issue)
}
}
@pull_requests.each { |pull_request|
threads << Thread.new {
find_closed_date_by_commit(pull_request)
}
}
threads.each { |thr| thr.join }
if @options[:verbose]
@@ -79,9 +80,11 @@ module GitHubChangelogGenerator
def find_closed_date_by_commit(issue)
unless issue['events'].nil?
#if it's PR -> then find "merged event", in case of usual issue -> fond closed date
compare_string = issue[:merged_at].nil? ? 'closed' : 'merged'
# reverse! - to find latest closed event. (event goes in date order)
issue['events'].reverse!.each { |event|
if event[:event].eql? 'closed'
if event[:event].eql? compare_string
if event[:commit_id].nil?
issue[:actual_date] = issue[:closed_at]
else
@@ -104,14 +107,9 @@ module GitHubChangelogGenerator
puts JSON.pretty_generate(json)
end
def exec_command(cmd)
exec_cmd = "cd #{$project_path} and #{cmd}"
%x[#{exec_cmd}]
end
def fetch_merged_at_pull_requests
if @options[:verbose]
print "Fetching pull requests...\r"
print "Fetching merged dates...\r"
end
response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed'
@@ -120,21 +118,22 @@ module GitHubChangelogGenerator
response.each_page do |page|
page_i += PER_PAGE_NUMBER
count_pages = response.count_pages
print "Fetching pull requests... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
print "Fetching merged dates... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\r"
pull_requests.concat(page)
end
print " \r"
if @options[:verbose]
puts "Received pull requests: #{pull_requests.count}"
end
@pull_requests.each { |pr|
fetched_pr = pull_requests.find { |fpr|
fpr.number == pr.number }
pr[:merged_at] = fetched_pr[:merged_at]
pull_requests.delete(fetched_pr)
}
if @options[:verbose]
puts 'Fetching merged dates... Done!'
end
end
def get_filtered_pull_requests
@@ -171,43 +170,6 @@ module GitHubChangelogGenerator
end
filtered_pull_requests
#
# #
#
#
# unless @options[:pull_request_labels].nil?
#
# if @options[:verbose]
# puts 'Filter all pull requests by labels.'
# end
#
# filtered_pull_requests = filtered_pull_requests.select { |pull_request|
# #fetch this issue to get labels array
# issue = @github.issues.get @options[:user], @options[:project], pull_request.number
#
# #compare is there any labels from @options[:labels] array
# issue_without_labels = !issue.labels.map { |label| label.name }.any?
#
# if @options[:verbose]
# puts "Filter request \##{issue.number}."
# end
#
# if @options[:pull_request_labels].any?
# select_by_label = (issue.labels.map { |label| label.name } & @options[:pull_request_labels]).any?
# else
# select_by_label = false
# end
#
# select_by_label | issue_without_labels
# }
#
# if @options[:verbose]
# puts "Filtered pull requests with specified labels and w/o labels: #{filtered_pull_requests.count}"
# end
# return filtered_pull_requests
# end
#
# filtered_pull_requests
end
def compund_changelog
@@ -267,7 +229,7 @@ module GitHubChangelogGenerator
log = ''
if @options[:unreleased]
if @options[:unreleased] && @all_tags.count != 0
unreleased_log = self.generate_log_between_tags(self.all_tags[0], nil)
if unreleased_log
log += unreleased_log
@@ -277,8 +239,9 @@ module GitHubChangelogGenerator
(1 ... self.all_tags.size).each { |index|
log += self.generate_log_between_tags(self.all_tags[index], self.all_tags[index-1])
}
log += generate_log_between_tags(nil, self.all_tags.last)
if @all_tags.count != 0
log += generate_log_between_tags(nil, self.all_tags.last)
end
log
end
@@ -341,12 +304,8 @@ module GitHubChangelogGenerator
tags
end
def github_token
if @options[:token]
return @github_token ||= @options[:token]
end
env_var = ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil
def fetch_github_token
env_var = @options[:token] ? @options[:token] : (ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil)
unless env_var
puts "Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found.".yellow
@@ -359,7 +318,7 @@ module GitHubChangelogGenerator
def generate_log_between_tags(older_tag, newer_tag)
# older_tag nil - means it's first tag, newer_tag nil - means it unreleased section
filtered_pull_requests = delete_by_time(@pull_requests, :merged_at, older_tag, newer_tag)
filtered_pull_requests = delete_by_time(@pull_requests, :actual_date, older_tag, newer_tag)
filtered_issues = delete_by_time(@issues, :actual_date, older_tag, newer_tag)
newer_tag_name = newer_tag.nil? ? nil : newer_tag['name']
@@ -416,7 +375,7 @@ module GitHubChangelogGenerator
def delete_by_time(array, hash_key, older_tag = nil, newer_tag = nil)
raise 'At least on of the tags should be not nil!' if (older_tag.nil? && newer_tag.nil?)
raise 'At least one of the tags should be not nil!' if (older_tag.nil? && newer_tag.nil?)
newer_tag_time = self.get_time_of_tag(newer_tag)
older_tag_time = self.get_time_of_tag(older_tag)
@@ -499,12 +458,11 @@ module GitHubChangelogGenerator
log += generate_log_from_array(enhancement_a, @options[:enhancement_prefix])
log += generate_log_from_array(bugs_a, @options[:bug_prefix])
log += generate_log_from_array(issues_a, @options[:issue_prefix])
end
if @options[:pulls]
# Generate pull requests:
log += generate_log_from_array(pull_requests, @options[:merge_prefix])
end
if @options[:pulls]
# Generate pull requests:
log += generate_log_from_array(pull_requests, @options[:merge_prefix])
end
log
@@ -629,27 +587,41 @@ module GitHubChangelogGenerator
return issues_wo_pr, pull_requests
end
def fetch_event_for_issues(filtered_issues)
def fetch_event_for_issues_and_pr
if @options[:verbose]
print "Fetching events for issues: 0/#{filtered_issues.count}\r"
print "Fetching events for issues and PR: 0/#{@issues.count + @pull_requests.count}\r"
end
# Async fetching events:
threads = []
i = 0
filtered_issues.each { |issue|
@issues.each { |issue|
threads << Thread.new {
obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: issue['number']
issue[:events] = obj.body
print "Fetching events for issues: #{i+1}/#{filtered_issues.count}\r"
print "Fetching events for issues and PR: #{i+1}/#{@issues.count + @pull_requests.count}\r"
i +=1
}
}
@pull_requests.each { |pull_request|
threads << Thread.new {
obj = @github.issues.events.list user: @options[:user], repo: @options[:project], issue_number: pull_request['number']
pull_request[:events] = obj.body
print "Fetching events for issues and PR: #{i+1}/#{@issues.count + @pull_requests.count}\r"
i +=1
}
}
threads.each { |thr| thr.join }
#to clear line from prev print
print " \r"
if @options[:verbose]
puts "Fetching events for issues: Done!"
puts "Fetching events for issues and PR: Done! #{i}/#{@issues.count + @pull_requests.count}"
end
end

View File

@@ -6,8 +6,8 @@ require_relative 'version'
module GitHubChangelogGenerator
class Parser
def self.parse_options
# :include_labels => %w(bug enhancement),
hash = {
options = {
:tag1 => nil,
:tag2 => nil,
:format => '%Y-%m-%d',
@@ -28,10 +28,9 @@ module GitHubChangelogGenerator
:unreleased => true,
:unreleased_label => 'Unreleased'
}
options = hash
parser = OptionParser.new { |opts|
opts.banner = 'Usage: changelog_generator [options]'
opts.banner = 'Usage: github_changelog_generator [options]'
opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo') do |last|
options[:user] = last
end
@@ -149,6 +148,12 @@ module GitHubChangelogGenerator
options[:tag2] = ARGV[1]
end
if options[:verbose]
puts 'Performing task with options:'
pp options
puts ''
end
options
end
end

View File

@@ -1,3 +1,3 @@
module GitHubChangelogGenerator
VERSION = '1.3.3'
VERSION = '1.3.6'
end