This commit is contained in:
Petr Korolev 2015-02-18 23:32:40 +02:00
parent 1dd82cddf4
commit c4f91f55ff
3 changed files with 27 additions and 12 deletions

View File

@ -76,8 +76,6 @@
- *Merged pull-request:* Add filter for pull-requests labels. \(option --filter-pull-requests\) [\#27](https://github.com/skywinder/Github-Changelog-Generator/pull/27) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Test Pull-Request SHOULD NOT APPEAR IN LOG! [\#26](https://github.com/skywinder/Github-Changelog-Generator/pull/26) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Add ability to insert authors of pull-requests \(--\[no-\]author option\) [\#25](https://github.com/skywinder/Github-Changelog-Generator/pull/25) ([skywinder](https://github.com/skywinder))
- *Merged pull-request:* Don't receive issues in case of --no-isses flag specied [\#24](https://github.com/skywinder/Github-Changelog-Generator/pull/24) ([skywinder](https://github.com/skywinder))

View File

@ -38,7 +38,15 @@ module GitHubChangelogGenerator
@generator = Generator.new(@options)
@all_tags = self.get_all_tags
@issues, @pull_requests = self.fetch_issues_and_pull_requests
if @options[:pulls]
@pull_requests = self.get_filtered_pull_requests
self.fetch_merged_at_pull_requests
else
@pull_requests = []
end
if @options[:issues]
@issues = self.get_filtered_issues
fetch_event_for_issues(@issues)
@ -96,7 +104,7 @@ module GitHubChangelogGenerator
%x[#{exec_cmd}]
end
def get_all_closed_pull_requests
def fetch_merged_at_pull_requests
if @options[:verbose]
print "Fetching pull requests...\r"
end
@ -116,12 +124,17 @@ module GitHubChangelogGenerator
puts "Received pull requests: #{pull_requests.count}"
end
pull_requests
@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)
}
end
def get_filtered_pull_requests
pull_requests = self.get_all_closed_pull_requests
pull_requests = @pull_requests
filtered_pull_requests = pull_requests
@ -144,7 +157,7 @@ module GitHubChangelogGenerator
# add issues without any labels
|issue| !issue.labels.map { |label| label.name }.any?
}
filtered_pull_requests.concat(issues_wo_labels)
filtered_pull_requests |= issues_wo_labels
end
@ -523,7 +536,7 @@ module GitHubChangelogGenerator
def get_filtered_issues
issues = self.get_all_issues
issues = @issues
filtered_issues = issues
@ -546,7 +559,7 @@ module GitHubChangelogGenerator
# add issues without any labels
|issue| !issue.labels.map { |label| label.name }.any?
}
filtered_issues.concat(issues_wo_labels)
filtered_issues |= issues_wo_labels
end
@ -558,7 +571,7 @@ module GitHubChangelogGenerator
end
def get_all_issues
def fetch_issues_and_pull_requests
if @options[:verbose]
print "Fetching closed issues...\r"
end
@ -581,10 +594,13 @@ module GitHubChangelogGenerator
end
# remove pull request from issues:
issues.select! { |x|
issues_wo_pr = issues.select { |x|
x.pull_request == nil
}
issues
pull_requests = issues.select { |x|
x.pull_request != nil
}
return issues_wo_pr, pull_requests
end
def fetch_event_for_issues(filtered_issues)

View File

@ -6,6 +6,7 @@ require_relative 'version'
module GitHubChangelogGenerator
class Parser
def self.parse_options
# :include_labels => %w(bug enhancement),
options = {:tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', :output => 'CHANGELOG.md', :exclude_labels => %w(duplicate question invalid wontfix), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :add_pr_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true}
parser = OptionParser.new { |opts|