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 "add" command #47

Merged
merged 4 commits into from
Nov 9, 2019
Merged

Add "add" command #47

merged 4 commits into from
Nov 9, 2019

Conversation

ordepdev
Copy link
Contributor

@ordepdev ordepdev commented Nov 9, 2019

The following sequence of commands:

changelog-tool new
changelog-tool unreleased -e
changelog-tool add fixed "We fixed some nasty bug." -e
changelog-tool add added "And we added some cool feature." -e
changelog-tool add changed "And changed some little things as well." -e
changelog-tool release 1.0.0

Will result in this nice changelog:

# Change Log

All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com/).

## [1.0.0] - 2019-11-09

### Fixed

- We fixed some nasty bug.

### Added

- And we added some cool feature.

### Changed

- And changed some little things as well.

@SeanTAllen
Copy link
Member

@ordepdev You checked in a binary, you'll want to remove that.

fun string(): String iso^ =>
if heading == _unreleased_heading then
Copy link
Member

Choose a reason for hiding this comment

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

i don't think you meant to remove all of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, if we don't remove this, it will print the unrelease thing with an empty body, without the entries that we're adding. That's why I removed it 👍

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this break the "unreleased" command?

Copy link
Contributor

Choose a reason for hiding this comment

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

The "unreleased" release should always show the fixed, added, and changed sections, even if they are empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect that this is the cause of the CI failure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah!

## [unreleased] - unreleased

### Fixed


### Added


### Changed

It's yielding ## [unreleased] - unreleased and makes the test fail.

I'm struggling to reach a point where I can print the empty sections only from unlreleased versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out that unreleased sections were being parsed as None, so I added an extra check for each section saying that if it's unreleased and the section is None, it will use the Section._empty(....) for printing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, for the parse test that's failing, a changelog must now contain all sections in "unreleased" because it can no longer assume that the "unreleased" release is either empty or nonexistent. It may be best to create a new class, Unreleased that uses Section instead of (Section | None) as field types. This would be simpler than treating it as any other release at this point.

Copy link
Contributor

@Theodus Theodus Nov 9, 2019

Choose a reason for hiding this comment

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

@ordepdev would you want to include the changes above in this PR? If not, I can do it after this PR is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would love to but I think it's better to let you do it and take a look at your changes after!

tests/main.pony Outdated Show resolved Hide resolved
@SeanTAllen
Copy link
Member

Looks like there is a failing test

@SeanTAllen
Copy link
Member

Awesome first-time contribution @ordepdev!

@SeanTAllen SeanTAllen added the changelog - added Automatically add "Added" CHANGELOG entry on merge label Nov 9, 2019
@SeanTAllen SeanTAllen changed the title Add the new "add" command Add "add" command Nov 9, 2019
Copy link
Contributor

@Theodus Theodus left a comment

Choose a reason for hiding this comment

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

Thanks @ordepdev! Looks good other than some style-guide-related issues and @SeanTAllen's comments

changelog-tool/main.pony Outdated Show resolved Hide resolved
changelog-tool/main.pony Outdated Show resolved Hide resolved
changelog-tool/main.pony Outdated Show resolved Hide resolved
changelog-tool/changelog.pony Outdated Show resolved Hide resolved
changed as Section
else error
end
section.entries.push("- " + entry)
Copy link
Contributor

Choose a reason for hiding this comment

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

A newline should be added to the end of the entry if it doesn't already have one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be done by using "String.contains" and appending "\n" or is there other idiomatic way of doing it?

edit_or_print(
filepath,
edit,
Changelog(parse(filepath, filename)?)?
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding .> create_unreleased() here before add_entry will likely solve the problem. An unreleased section should be created anyway if someone is using this command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, creating a new "unreleased" release creates new empty sections.

changelog-tool new
changelog-tool unreleased -e
changelog-tool add fixed "We fixed some nasty bug." -e
changelog-tool add added "And we added some cool feature." -e
changelog-tool add changed "And changed some little things as well." -e
changelog-tool release 1.0.0

Currently, this works as expected. If I add that command only the last "changed" will be reflected in the file, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, the problem is that the "unreleased" release must contain all sections if it exists. Previously the string function would assume that it is empty if it exists. But this is no longer a reasonable assumption, so the sections must be created if they don't exist. That's why it may be useful to create a new class for unreleased that reflects the requirement that the sections cannot have type None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, make the types do the work instead.

changelog-tool/changelog.pony Outdated Show resolved Hide resolved
changelog-tool/changelog.pony Outdated Show resolved Hide resolved
Copy link
Contributor

@Theodus Theodus left a comment

Choose a reason for hiding this comment

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

OK, looks good. I'll make a followup PR with some additional changes to how the "unreleased" release is treated.

@Theodus Theodus merged commit cf0262a into ponylang:master Nov 9, 2019
github-actions bot pushed a commit that referenced this pull request Nov 9, 2019
@ordepdev
Copy link
Contributor Author

ordepdev commented Nov 9, 2019

Nice, thanks for all the help! Will look this closely for changes 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - added Automatically add "Added" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants