Fix #44.
This commit is contained in:
parent
1dd82cddf4
commit
c4f91f55ff
|
@ -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:* 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:* 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))
|
- *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))
|
||||||
|
|
|
@ -38,7 +38,15 @@ module GitHubChangelogGenerator
|
||||||
@generator = Generator.new(@options)
|
@generator = Generator.new(@options)
|
||||||
|
|
||||||
@all_tags = self.get_all_tags
|
@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
|
@pull_requests = self.get_filtered_pull_requests
|
||||||
|
self.fetch_merged_at_pull_requests
|
||||||
|
else
|
||||||
|
@pull_requests = []
|
||||||
|
end
|
||||||
|
|
||||||
if @options[:issues]
|
if @options[:issues]
|
||||||
@issues = self.get_filtered_issues
|
@issues = self.get_filtered_issues
|
||||||
fetch_event_for_issues(@issues)
|
fetch_event_for_issues(@issues)
|
||||||
|
@ -96,7 +104,7 @@ module GitHubChangelogGenerator
|
||||||
%x[#{exec_cmd}]
|
%x[#{exec_cmd}]
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_all_closed_pull_requests
|
def fetch_merged_at_pull_requests
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
print "Fetching pull requests...\r"
|
print "Fetching pull requests...\r"
|
||||||
end
|
end
|
||||||
|
@ -116,12 +124,17 @@ module GitHubChangelogGenerator
|
||||||
puts "Received pull requests: #{pull_requests.count}"
|
puts "Received pull requests: #{pull_requests.count}"
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def get_filtered_pull_requests
|
def get_filtered_pull_requests
|
||||||
|
|
||||||
pull_requests = self.get_all_closed_pull_requests
|
pull_requests = @pull_requests
|
||||||
filtered_pull_requests = pull_requests
|
filtered_pull_requests = pull_requests
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,7 +157,7 @@ module GitHubChangelogGenerator
|
||||||
# add issues without any labels
|
# add issues without any labels
|
||||||
|issue| !issue.labels.map { |label| label.name }.any?
|
|issue| !issue.labels.map { |label| label.name }.any?
|
||||||
}
|
}
|
||||||
filtered_pull_requests.concat(issues_wo_labels)
|
filtered_pull_requests |= issues_wo_labels
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -523,7 +536,7 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
def get_filtered_issues
|
def get_filtered_issues
|
||||||
|
|
||||||
issues = self.get_all_issues
|
issues = @issues
|
||||||
|
|
||||||
filtered_issues = issues
|
filtered_issues = issues
|
||||||
|
|
||||||
|
@ -546,7 +559,7 @@ module GitHubChangelogGenerator
|
||||||
# add issues without any labels
|
# add issues without any labels
|
||||||
|issue| !issue.labels.map { |label| label.name }.any?
|
|issue| !issue.labels.map { |label| label.name }.any?
|
||||||
}
|
}
|
||||||
filtered_issues.concat(issues_wo_labels)
|
filtered_issues |= issues_wo_labels
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -558,7 +571,7 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_all_issues
|
def fetch_issues_and_pull_requests
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
print "Fetching closed issues...\r"
|
print "Fetching closed issues...\r"
|
||||||
end
|
end
|
||||||
|
@ -581,10 +594,13 @@ module GitHubChangelogGenerator
|
||||||
end
|
end
|
||||||
|
|
||||||
# remove pull request from issues:
|
# remove pull request from issues:
|
||||||
issues.select! { |x|
|
issues_wo_pr = issues.select { |x|
|
||||||
x.pull_request == nil
|
x.pull_request == nil
|
||||||
}
|
}
|
||||||
issues
|
pull_requests = issues.select { |x|
|
||||||
|
x.pull_request != nil
|
||||||
|
}
|
||||||
|
return issues_wo_pr, pull_requests
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_event_for_issues(filtered_issues)
|
def fetch_event_for_issues(filtered_issues)
|
||||||
|
|
|
@ -6,6 +6,7 @@ require_relative 'version'
|
||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
class Parser
|
class Parser
|
||||||
def self.parse_options
|
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}
|
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|
|
parser = OptionParser.new { |opts|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user