Skip to content

Linting updates, spec fixes #680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ matrix:
- rvm: 2.2.9
install: true # This skips 'bundle install'
script: gem build github_changelog_generator && bundle install
gemfile: spec/install-gem-in-bundler.gemfile
gemfile: spec/install_gem_in_bundler.gemfile
after_success: true # This skips 'codeclimate-test-reporter'
- rvm: 2.3.6
- rvm: 2.4.3
Expand Down
2 changes: 1 addition & 1 deletion lib/github_changelog_generator/generator/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def generate_body(pull_requests, issues)
# @return [Array] Section objects.
def default_sections
[
Section.new(name: "summary", prefix: @options[:summary_prefix], labels: @options[:summary_labels], options: @options, body_only:true),
Section.new(name: "summary", prefix: @options[:summary_prefix], labels: @options[:summary_labels], options: @options, body_only: true),
Section.new(name: "breaking", prefix: @options[:breaking_prefix], labels: @options[:breaking_labels], options: @options),
Section.new(name: "enhancements", prefix: @options[:enhancement_prefix], labels: @options[:enhancement_labels], options: @options),
Section.new(name: "bugs", prefix: @options[:bug_prefix], labels: @options[:bug_labels], options: @options),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def associate_tagged_prs(tags, prs, total)
# weird like that apparently. Check for a rebased comment before erroring.
no_events_pr = associate_rebase_comment_prs(tags, [pr], total)
raise StandardError, "No merge sha found for PR #{pr['number']} via the GitHub API" unless no_events_pr.empty?

found = true
i += 1
print("Associating PRs with tags: #{i}/#{total}\r") if @options[:verbose]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ def delete_by_time(issues, hash_key = "actual_date", older_tag = nil, newer_tag

def ensure_older_tag(older_tag, newer_tag)
return older_tag if older_tag

idx = sorted_tags.index { |t| t["name"] == newer_tag["name"] }
# skip if we are already at the oldest element
return if idx == sorted_tags.size - 1

sorted_tags[idx - 1]
end

Expand Down
1 change: 1 addition & 0 deletions lib/github_changelog_generator/generator/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def get_string_for_issue(issue)
def issue_line_with_body(line, issue)
return issue["body"] if @body_only && issue["body"].present?
return line if !@options[:issue_line_body] || issue["body"].blank?

# get issue body till first line break
body_paragraph = body_till_first_break(issue["body"])
# remove spaces from begining and end of the string
Expand Down
2 changes: 2 additions & 0 deletions lib/github_changelog_generator/octo_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def initialize(options = {})

def prepare_cache
return unless @http_cache

@cache_file = @options.fetch(:cache_file) { File.join(Dir.tmpdir, "github-changelog-http-cache") }
@cache_log = @options.fetch(:cache_log) { File.join(Dir.tmpdir, "github-changelog-logger.log") }
init_cache
Expand Down Expand Up @@ -253,6 +254,7 @@ def fetch_compare(older, newer)
unless @compares["#{older}...#{newer}"]
compare_data = check_github_response { @client.compare(user_project, older, newer || "HEAD") }
raise StandardError, "Sha #{older} and sha #{newer} are not related; please file a github-changelog-generator issues and describe how to replicate this issue." if compare_data["status"] == "diverged"

@compares["#{older}...#{newer}"] = stringify_keys_deep(compare_data.to_hash)
end
@compares["#{older}...#{newer}"]
Expand Down
1 change: 1 addition & 0 deletions lib/github_changelog_generator/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def load_custom_ruby_files
# Pretty-prints a censored options hash, if :verbose.
def print_options
return unless self[:verbose]

Helper.log.info "Using these options:"
# For ruby 2.5.0+
censored_values.each do |key, value|
Expand Down
2 changes: 2 additions & 0 deletions lib/github_changelog_generator/parser_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def initialize(options, file = open_settings_file)
# Sets options using configuration file content
def parse!
return unless @file

@file.each_with_index { |line, i| parse_line!(line, i + 1) }
@file.close
end
Expand All @@ -46,6 +47,7 @@ def open_settings_file

def parse_line!(line, line_number)
return if non_configuration_line?(line)

option_name, value = extract_pair(line)
@options[option_key_for(option_name)] = convert_value(value, option_name)
rescue StandardError
Expand Down
10 changes: 6 additions & 4 deletions spec/unit/generator/entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,9 @@ def default_sections

subject { described_class.new(options) }

it "returns 8 sections" do
expect(entry_sections.size).to eq 8
it "returns 9 sections" do
entry_sections.each { |sec| pp(sec.name) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, line 542 & line 727 are debug code...
entry_sections.each { |sec| pp(sec.name) } is unnecessary.

expect(entry_sections.size).to eq 9
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell when this test began failing?

Has the behavior changed, like "there's a new expected Section"?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! And you did!

end

it "returns default sections" do
Expand Down Expand Up @@ -722,8 +723,9 @@ def default_sections

subject { described_class.new(options) }

it "returns 9 sections" do
expect(entry_sections.size).to eq 9
it "returns 10 sections" do
entry_sections.each { |sec| pp(sec.name) }
expect(entry_sections.size).to eq 10
end

it "returns default sections" do
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/octo_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@
"commit_url" =>
"https://api.github.com/repos/skywinder/changelog_test/commits/decfe840d1a1b86e0c28700de5362d3365a29555",
"created_at" => "2015-07-16T12:21:16Z" }
commit = fetcher.fetch_commit(event)
commit = fetcher.fetch_commit(event["commit_id"])

expectations = [
%w[sha decfe840d1a1b86e0c28700de5362d3365a29555],
Expand Down