Skip to content

Commit

Permalink
fixing rubocop and removing original fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Waage authored and olleolleolle committed Sep 29, 2016
1 parent 0e948fb commit ef9867c
Show file tree
Hide file tree
Showing 16 changed files with 435 additions and 652 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ end

group :test do
gem "vcr"
gem "multi_json"
gem "webmock"
gem "coveralls", "~>0.8", require: false
gem "simplecov", "~>0.10", require: false
Expand Down
1 change: 0 additions & 1 deletion lib/github_changelog_generator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "github_api"
require "octokit"
require 'faraday-http-cache'
require "logger"
Expand Down
6 changes: 3 additions & 3 deletions lib/github_changelog_generator/array.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class Array
def stringify_keys_deep!
new_ar = []
self.each do |value|
each do |value|
new_value = value
if value.is_a? Hash or value.is_a? Array
if value.is_a?(Hash) || value.is_a?(Array)
new_value = value.stringify_keys_deep!
end
new_ar << new_value
end
new_ar
end
end
end
226 changes: 0 additions & 226 deletions lib/github_changelog_generator/fetcher.rb

This file was deleted.

13 changes: 6 additions & 7 deletions lib/github_changelog_generator/generator/generator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# frozen_string_literal: true
require_relative "../fetcher"
require_relative "../octo_fetcher"
require_relative "generator_generation"
require_relative "generator_fetcher"
Expand Down Expand Up @@ -107,13 +106,13 @@ def parse_by_sections(issues, pull_requests)

issues.each do |dict|
added = false
dict['labels'].each do |label|
if @options[:bug_labels].include? label['name']
dict["labels"].each do |label|
if @options[:bug_labels].include? label["name"]
bugs_a.push dict
added = true
next
end
if @options[:enhancement_labels].include? label['name']
if @options[:enhancement_labels].include? label["name"]
enhancement_a.push dict
added = true
next
Expand All @@ -124,13 +123,13 @@ def parse_by_sections(issues, pull_requests)

added_pull_requests = []
pull_requests.each do |pr|
pr['labels'].each do |label|
if @options[:bug_labels].include? label['name']
pr["labels"].each do |label|
if @options[:bug_labels].include? label["name"]
bugs_a.push pr
added_pull_requests.push pr
next
end
if @options[:enhancement_labels].include? label['name']
if @options[:enhancement_labels].include? label["name"]
enhancement_a.push pr
added_pull_requests.push pr
next
Expand Down
17 changes: 9 additions & 8 deletions lib/github_changelog_generator/generator/generator_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ def detect_actual_closed_dates(issues)
# Fill :actual_date parameter of specified issue by closed date of the commit, if it was closed by commit.
# @param [Hash] issue
def find_closed_date_by_commit(issue)
unless issue['events'].nil?
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"
compare_string = issue["merged_at"].nil? ? "closed" : "merged"
# reverse! - to find latest closed event. (event goes in date order)
issue['events'].reverse!.each do |event|
if event['event'].eql? compare_string
issue["events"].reverse!.each do |event|
if event["event"].eql? compare_string
set_date_from_event(event, issue)
break
end
Expand All @@ -69,16 +69,17 @@ def find_closed_date_by_commit(issue)
# @param [Hash] event
# @param [Hash] issue
def set_date_from_event(event, issue)
if event['commit_id'].nil?
issue['actual_date'] = issue['closed_at']
if event["commit_id"].nil?
issue["actual_date"] = issue["closed_at"]
else
begin
commit = @fetcher.fetch_commit(event)
issue['actual_date'] = commit['commit']['author']['date']
issue["actual_date"] = commit["commit"]["author"]["date"]

# issue['actual_date'] = commit['author']['date']
rescue
puts "Warning: Can't fetch commit #{event['commit_id']}. It is probably referenced from another repo."
issue['actual_date'] = issue['closed_at']
issue["actual_date"] = issue["closed_at"]
end
end
end
Expand Down
13 changes: 6 additions & 7 deletions lib/github_changelog_generator/generator/generator_generation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ def generate_log_between_tags(older_tag, newer_tag)
#
# @return [Array] filtered issues and pull requests
def filter_issues_for_tags(newer_tag, older_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)
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"]

Expand Down Expand Up @@ -167,7 +166,7 @@ def generate_unreleased_section
# @param [Hash] issue Fetched issue from GitHub
# @return [String] Markdown-formatted single issue
def get_string_for_issue(issue)
encapsulated_title = encapsulate_string issue['title']
encapsulated_title = encapsulate_string issue["title"]

title_with_number = "#{encapsulated_title} [\\##{issue['number']}](#{issue['html_url']})"
issue_line_with_user(title_with_number, issue)
Expand All @@ -178,13 +177,13 @@ def get_string_for_issue(issue)
def issue_line_with_user(line, issue)
return line if !@options[:author] || issue.pull_request.nil?

user = issue['user']
user = issue["user"]
return "#{line} ({Null user})" unless user

if @options[:usernames_as_github_logins]
"#{line} (@#{user['login']})"
"#{line} (@#{user["login"]})"
else
"#{line} ([#{user['login']}](#{user['html_url']}))"
"#{line} ([#{user["login"]}](#{user["html_url"]}))"
end
end
end
Expand Down
Loading

0 comments on commit ef9867c

Please sign in to comment.