Skip to content
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

Add new :append_datetime param and fix dates to UTC. #53

Merged
merged 5 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 13 additions & 4 deletions lib/fastlane/plugin/changelog/actions/stamp_changelog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@ def self.run(params)
UI.important("WARNING: No changes in [Unreleased] section to stamp!")
else
section_identifier = params[:section_identifier] unless params[:section_identifier].to_s.empty?
stamp_date = params[:stamp_date]
stamp_date_time = params[:stamp_date_time]
stamp_date = params[:stamp_date_time] ? false : params[:stamp_date]
git_tag = params[:git_tag]
placeholder_line = params[:placeholder_line]

stamp(changelog_path, section_identifier, stamp_date, git_tag, placeholder_line)
stamp(changelog_path, section_identifier, stamp_date, stamp_date_time, git_tag, placeholder_line)
end
end

def self.stamp(changelog_path, section_identifier, stamp_date, git_tag, placeholder_line)
def self.stamp(changelog_path, section_identifier, stamp_date, stamp_date_time, git_tag, placeholder_line)
# 1. Update [Unreleased] section with given identifier
Actions::UpdateChangelogAction.run(changelog_path: changelog_path,
section_identifier: UNRELEASED_IDENTIFIER,
updated_section_identifier: section_identifier,
append_date: stamp_date,
append_date_time: stamp_date_time,
excluded_placeholder_line: placeholder_line)

file_content = ""
Expand Down Expand Up @@ -131,8 +133,15 @@ def self.available_options
is_string: true),
FastlaneCore::ConfigItem.new(key: :stamp_date,
env_name: "FL_STAMP_CHANGELOG_SECTION_STAMP_DATE",
description: "Specifies whether the current date should be appended to section identifier",
description: "Specifies whether the current UTC date should be appended to section identifier",
default_value: true,
is_string: false,
optional: true),
FastlaneCore::ConfigItem.new(key: :stamp_date_time,
env_name: "FL_STAMP_CHANGELOG_SECTION_STAMP_DATE_TIME",
description: "Specifies whether the current UTC date and time should be appended to section identifier",
default_value: false,
is_string: false,
optional: true),
FastlaneCore::ConfigItem.new(key: :git_tag,
env_name: "FL_STAMP_CHANGELOG_GIT_TAG",
Expand Down
19 changes: 16 additions & 3 deletions lib/fastlane/plugin/changelog/actions/update_changelog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,15 @@ def self.run(params)
line_old = line.dup
line.sub!(section_name, new_section_identifier)

if params[:append_date]
now = Time.now.strftime("%Y-%m-%d")
if params[:append_date_time] || params[:append_date]
if params[:append_date_time]
now = Time.now.utc.iso8601
ENV["FL_UPDATE_APPEND_DATE_TIME_VAL"] = now
else
now = Time.now.utc.strftime("%Y-%m-%d")
ENV["FL_UPDATE_APPEND_DATE_VAL"] = now
end

line.concat(" - " + now)
line.delete!(line_separator) # remove line break, because concatenation adds line break between section identifer & date
line.concat(line_separator) # add line break to the end of the string, in order to start next line on the next line
Expand Down Expand Up @@ -116,10 +123,16 @@ def self.available_options
optional: true),
FastlaneCore::ConfigItem.new(key: :append_date,
env_name: "FL_UPDATE_CHANGELOG_APPEND_DATE",
description: "Appends the current date in YYYY-MM-DD format after the section identifier",
description: "Appends the current UTC date in YYYY-MM-DD format after the section identifier",
default_value: true,
is_string: false,
optional: true),
FastlaneCore::ConfigItem.new(key: :append_date_time,
env_name: "FL_UPDATE_CHANGELOG_APPEND_DATE_TIME",
description: "Appends the current UTC date in YYYY-MM-DDTHH:MM:SSZ format after the section identifier",
default_value: false,
is_string: false,
optional: true),
FastlaneCore::ConfigItem.new(key: :excluded_placeholder_line,
env_name: "FL_UPDATE_CHANGELOG_EXCLUDED_PLACEHOLDER_LINE",
description: "Placeholder string to be ignored in updated section",
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/changelog/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module Changelog
VERSION = "0.15.0"
VERSION = "0.15.1"
end
end