code cleanup. remove duplicate code
This commit is contained in:
		
							parent
							
								
									31c5ac4c55
								
							
						
					
					
						commit
						e1161f9d90
					
				| @ -46,17 +46,9 @@ module GitHubChangelogGenerator | |||||||
|       @all_tags = get_all_tags |       @all_tags = get_all_tags | ||||||
|       @issues, @pull_requests = fetch_issues_and_pull_requests |       @issues, @pull_requests = fetch_issues_and_pull_requests | ||||||
| 
 | 
 | ||||||
|       if @options[:pulls] |       @options[:pulls] ? @pull_requests = get_filtered_pull_requests : @pull_requests = [] | ||||||
|         @pull_requests = get_filtered_pull_requests |  | ||||||
|       else |  | ||||||
|         @pull_requests = [] |  | ||||||
|       end |  | ||||||
| 
 | 
 | ||||||
|       if @options[:issues] |       @options[:issues] ? @issues = get_filtered_issues : @issues = [] | ||||||
|         @issues = get_filtered_issues |  | ||||||
|       else |  | ||||||
|         @issues = [] |  | ||||||
|       end |  | ||||||
| 
 | 
 | ||||||
|       fetch_event_for_issues_and_pr |       fetch_event_for_issues_and_pr | ||||||
|       detect_actual_closed_dates |       detect_actual_closed_dates | ||||||
| @ -162,12 +154,7 @@ module GitHubChangelogGenerator | |||||||
|         } |         } | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       unless @options[:exclude_labels].nil? |       filtered_pull_requests = exclude_issues_by_labels(filtered_pull_requests) | ||||||
|         filtered_pull_requests = filtered_pull_requests.select { |issue| |  | ||||||
|           # delete all labels from @options[:exclude_labels] array |  | ||||||
|           !(issue.labels.map(&:name) & @options[:exclude_labels]).any? |  | ||||||
|         } |  | ||||||
|       end |  | ||||||
| 
 | 
 | ||||||
|       if @options[:add_issues_wo_labels] |       if @options[:add_issues_wo_labels] | ||||||
|         issues_wo_labels = @pull_requests.select { |issue| |         issues_wo_labels = @pull_requests.select { |issue| | ||||||
| @ -183,6 +170,18 @@ module GitHubChangelogGenerator | |||||||
|       filtered_pull_requests |       filtered_pull_requests | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  |     # delete all labels with labels from @options[:exclude_labels] array | ||||||
|  |     # @param [Array] issues | ||||||
|  |     # @return [Array] filtered array | ||||||
|  |     def exclude_issues_by_labels(issues) | ||||||
|  |       unless @options[:exclude_labels].nil? | ||||||
|  |         issues = issues.select { |issue| | ||||||
|  |           !(issue.labels.map(&:name) & @options[:exclude_labels]).any? | ||||||
|  |         } | ||||||
|  |       end | ||||||
|  |       issues | ||||||
|  |     end | ||||||
|  | 
 | ||||||
|     # The entry point of this script to generate change log |     # The entry point of this script to generate change log | ||||||
|     # @raise (ChangelogGeneratorError) Is thrown when one of specified tags was not found in list of tags. |     # @raise (ChangelogGeneratorError) Is thrown when one of specified tags was not found in list of tags. | ||||||
|     def compound_changelog |     def compound_changelog | ||||||
| @ -551,12 +550,7 @@ module GitHubChangelogGenerator | |||||||
|         } |         } | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       unless @options[:exclude_labels].nil? |       filtered_issues = exclude_issues_by_labels(filtered_issues) | ||||||
|         filtered_issues = filtered_issues.select { |issue| |  | ||||||
|           # delete all labels from @options[:exclude_labels] array |  | ||||||
|           !(issue.labels.map(&:name) & @options[:exclude_labels]).any? |  | ||||||
|         } |  | ||||||
|       end |  | ||||||
| 
 | 
 | ||||||
|       if @options[:add_issues_wo_labels] |       if @options[:add_issues_wo_labels] | ||||||
|         issues_wo_labels = issues.select { |issue| |         issues_wo_labels = issues.select { |issue| | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Petr Korolev
						Petr Korolev