This commit is contained in:
Petr Korolev 2015-05-19 11:47:56 +03:00
parent d0defc4c9b
commit ec7c98758c
3 changed files with 16 additions and 14 deletions

View File

@ -6,10 +6,6 @@
**Merged pull requests:**
- this pr will be closed and shouldn't appear in changelog [\#7](https://github.com/skywinder/changelog_test/pull/7) ([skywinder](https://github.com/skywinder))
- This PR SHOULD NOT appear in change log! [\#6](https://github.com/skywinder/changelog_test/pull/6) ([skywinder](https://github.com/skywinder))
- Add automatically generated change log file. [\#5](https://github.com/skywinder/changelog_test/pull/5) ([skywinder](https://github.com/skywinder))
## [v0.0.3](https://github.com/skywinder/changelog_test/tree/v0.0.3) (2015-03-04)

View File

@ -32,7 +32,8 @@ module GitHubChangelogGenerator
# @all_tags = get_filtered_tags
@all_tags = @fetcher.get_all_tags
@issues, @pull_requests = @fetcher.fetch_issues_and_pull_requests
# TODO: refactor this double asssign of @issues and @pull_requests and move all logic in one method
@issues, @pull_requests = @fetcher.fetch_closed_issues_and_pr
@pull_requests = @options[:pulls] ? get_filtered_pull_requests : []
@ -120,7 +121,7 @@ module GitHubChangelogGenerator
# And exclude all from :exclude_labels array.
# @return [Array] filtered PR's
def get_filtered_pull_requests
fetch_merged_at_pull_requests
filter_merged_pull_requests
filtered_pull_requests = include_issues_by_labels(@pull_requests)
@ -133,14 +134,15 @@ module GitHubChangelogGenerator
filtered_pull_requests
end
# This method fetch missing required attributes for pull requests
# This method filter only merged PR and
# fetch missing required attributes for pull requests
# :merged_at - is a date, when issue PR was merged.
# More correct to use this date, not closed date.
def fetch_merged_at_pull_requests
# More correct to use merged date, rather than closed date.
def filter_merged_pull_requests
if @options[:verbose]
print "Fetching merged dates...\r"
end
pull_requests = @fetcher.fetch_pull_requests
pull_requests = @fetcher.fetch_closed_pull_requests
@pull_requests.each { |pr|
fetched_pr = pull_requests.find { |fpr|
@ -149,6 +151,10 @@ module GitHubChangelogGenerator
pr[:merged_at] = fetched_pr[:merged_at]
pull_requests.delete(fetched_pr)
}
@pull_requests.select! do |pr|
!pr[:merged_at].nil?
end
end
# Include issues with labels, specified in :include_labels

View File

@ -96,8 +96,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
# This method fetch all closed issues and separate them to pull requests and pure issues
# (pull request is kind of issue in term of GitHub)
# @return [Tuple] with issues and pull requests
def fetch_issues_and_pull_requests
# @return [Tuple] with (issues, pull-requests)
def fetch_closed_issues_and_pr
if @options[:verbose]
print "Fetching closed issues...\r"
end
@ -124,7 +124,7 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
@logger.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow
end
# remove pull request from issues:
# separate arrays of issues and pull requests:
issues.partition do |x|
x[:pull_request].nil?
end
@ -132,7 +132,7 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
# Fetch all pull requests. We need them to detect :merged_at parameter
# @return [Array] all pull requests
def fetch_pull_requests
def fetch_closed_pull_requests
pull_requests = []
begin
response = @github.pull_requests.list @options[:user], @options[:project], state: "closed"