Skip to content

Use UTC for future release date #926

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
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
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
github_changelog_generator (1.15.2)
activesupport
async (>= 1.25.0)
async-http-faraday
faraday-http-cache
multi_json
Expand Down
2 changes: 1 addition & 1 deletion lib/github_changelog_generator/generator/generator_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def get_time_of_tag(tag_name)
# @return [Array] link, name and time of the tag
def detect_link_tag_time(newer_tag)
# if tag is nil - set current time
newer_tag_time = newer_tag.nil? ? Time.new : get_time_of_tag(newer_tag)
newer_tag_time = newer_tag.nil? ? Time.new.getutc : get_time_of_tag(newer_tag)

# if it's future release tag - set this value
if newer_tag.nil? && options[:future_release]
Expand Down
27 changes: 27 additions & 0 deletions spec/unit/generator/generator_tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@ def tags_from_strings(tags_strings)
end
end

describe "#detect_link_tag_time" do
let(:newer_tag) { nil }

let(:default_options) { GitHubChangelogGenerator::Parser.default_options.merge(verbose: false) }
let(:options) do
{
future_release: "2.0.0"
}
end
let(:generator) { described_class.new(default_options.merge(options)) }

subject do
generator.detect_link_tag_time(newer_tag)
end

context "When the local date is not the same as the UTC date" do
before do
# 2020-12-27T17:00:00-10:00 is 2020-12-28T03:00:00Z.
# GitHub API date & time use UTC, so this instant when converted as a
# date should be 2020-12-28.
expect(Time).to receive(:new).and_return(Time.new(2020, 12, 27, 17, 0, 0, "-10:00"))
end

it { is_expected.to eq(["2.0.0", "2.0.0", Time.gm(2020, 12, 28, 3)]) }
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding a spec, this helps catch regressions. But, perhaps a code comment, or an "it" being described with a note that captures the essence of the change (should always use UTC since GitHub uses UTC for the things we care about, etc).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol, I was focusing what was being tested and the reason for this has been completely lost!

I amended my commit to add a context and an explicit comment. Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks perfect, and will guide the interested reader in the future.

Thanks, @smortex for the repairs!


describe "#tag_section_mapping" do
let(:all_tags) { tags_from_strings(%w[8 7 6 5 4 3 2 1]) }
let(:sorted_tags) { all_tags }
Expand Down