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

Re-format CHANGELOG.md #3905

Merged
merged 1 commit into from
Jan 18, 2019
Merged

Re-format CHANGELOG.md #3905

merged 1 commit into from
Jan 18, 2019

Conversation

ybiquitous
Copy link
Member

@ybiquitous ybiquitous commented Jan 17, 2019

Which issue, if any, is this issue related to?

Closes #3901

Is there anything in the PR that needs further explanation?

Changes summary:

  • Introduce a new 1st level heading
  • Change headings (including each version number) from 1st level to 2nd level
  • Add GitHub compare link between tags
  • Update descriptions related to CHANGELOG.md in developer guide
I wrote the following Ruby script for this task:
original_content = File.read("CHANGELOG.md")

versions = original_content.lines.
             select { |line| line.start_with?("#") }.
             map { |line| line.match(/# ([0-9\.-]+)\b/)[1] }

compare_urls = versions.map.with_index do |version, index|
  prev_version = versions[index + 1]
  next unless prev_version

  if prev_version == "0.1.0"
    prev_version = "v0.1.0"
  end

  if prev_version == "3.0.0-3.0.2"
    "[#{version}]: https://github.com/stylelint/stylelint/compare/3.0.2...#{version}"
  elsif version == "3.0.0-3.0.2"
    "[#{version}]: https://github.com/stylelint/stylelint/compare/2.3.7...3.0.2"
  else
    "[#{version}]: https://github.com/stylelint/stylelint/compare/#{prev_version}...#{version}"
  end
end.compact

updated_content = original_content.gsub(/^# ([0-9\.-]+)/m) do |_|
  if $1 == versions.last
    "## #{$1}"
  else
    "## [#{$1}][]"
  end
end

updated_content = <<~EOF
# Changelog

All notable changes to this project are documented in this file.

## [Head][]

#{updated_content}
[Head]: https://github.com/stylelint/stylelint/compare/#{versions.first}...HEAD
#{compare_urls.join("\n")}
EOF

File.write("CHANGELOG.md", updated_content)

@ybiquitous ybiquitous added status: wip is being worked on by someone and removed status: wip is being worked on by someone labels Jan 17, 2019
- Introduce a new 1st level heading
- Change headings (including each version number) from 1st level to 2nd level
- Add GitHub compare link between tags
- Update descriptions related to `CHANGELOG.md` in developer guide
@ybiquitous ybiquitous removed the status: wip is being worked on by someone label Jan 17, 2019
Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

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

LGTM!

Nice work with the script.

We'll only know if this new format works correctly with npmpub when we next release. Fingers crossed...

@jeddy3 jeddy3 merged commit fb7b8bf into stylelint:master Jan 18, 2019
@ybiquitous ybiquitous deleted the reformat-changelog branch January 18, 2019 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants