-
Notifications
You must be signed in to change notification settings - Fork 231
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
feat: add --sort [TYPE]
flag
#78
Conversation
--sort-by-date
flag for previous functionality
10acacd
to
cf0ecc6
Compare
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
yes please! |
@sanderblue can you rebase this so we can see if we can get the tests to run & pass? We have a few new maintainers/contributors to the project, so now is the time to kick this into high gear. This is technically not backwards compatible, so maybe we should wait to merge this and add |
@ghostsquad good call on the flag idea. I should be able to address this relatively soon - hopefully within the next couple days. |
cf0ecc6
to
2bc7aff
Compare
Pull Request Test Coverage Report for Build 695618253
💛 - Coveralls |
2bc7aff
to
3a3564a
Compare
This sounds really cool. To be frank I haven't actually looked at the changeset yet, but wanted to suggest converting the new flag from |
3a3564a
to
c2eb966
Compare
--sort-by-date
flag for previous functionality--sort-by-version
flag
Hi @khos2ow, thanks for the feedback, but that kind of feels like premature optimization at this stage and that would also add additional code complexity because some form of validation would be needed to ensure a valid type string was passed which could grow over time. Plus right now there are only two ways to sort and I'm not sure if there would be any other ways to sort that make sense here other than maybe ascending or descending (which could be by date or by version as well). That being said, if there's a use case I'm missing I'm all ears (or eyes in this case) 🙂 |
I don't think it's that far fetched to provide a Looking at other tools, it looks like https://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html
|
Is it possible to add a config option at the same time? |
I think I agree with @sanderblue that this feels like premature optimization to include a sort string right now, but perhaps others could change that after merge? What other sorting methods would we implement other than the default behavior, or what this flag introduces? Also, 10 files changed, 3 commits, and the contributor included tests. This seems like a great addition to me. If other folks want a config option, perhaps that can be included after merge also. |
Just adding my take that the current work is great and the call outs a sort type and config sound like great iterations to extend this feature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work here! Like the sort by feature. Can you please rebase from master
to pick up the changes to urfave/cli/v2
. You will need to address one compatibility issue with the new CLI flag.
Also, I left a comment concerning the changes to the Makefile
.
Awesome work!
cmd/git-chglog/main.go
Outdated
@@ -126,6 +126,12 @@ func CreateApp(actionFunc cli.ActionFunc) *cli.App { | |||
Usage: "Regular expression of tag filter. Is specified, only matched tags will be picked", | |||
}, | |||
|
|||
// sort-by-version | |||
cli.BoolFlag{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be needed after the rebase with current master
and the bump to urfave/cli/v2
cli.BoolFlag{ | |
&cli.BoolFlag{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Should be good to go now 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review as well!
Makefile
Outdated
@@ -20,3 +20,35 @@ install: | |||
.PHONY: changelog | |||
changelog: | |||
@git-chglog --next-tag $(tag) $(tag) | |||
|
|||
|
|||
.PHONY: compile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these changes be moved out to a separate PR please? While potentially useful, they are not related to the addition of the sort by feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, no worries :)
038d6cb
to
346111a
Compare
@clok I've updated the PR per latest feedback. Thanks for all the additional reviews and feedback as well 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the follow up. Dropped an in-line comment with a link to #112 that we can use to follow up with a more robust sort flag.
Appreciate the follow through and contribution.
tag_reader.go
Outdated
if r.sortByVersion { | ||
err := r.sortTagsByVersion(tags) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} else { | ||
r.sortTagsByDate(tags) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting the addition of #112 to follow up with the support for a more robust sort feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @sanderblue, LGTM!
I think you need to rebase one final time on master
to be able to proceed with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanderblue we have merged #124 which provides this feature via a configuration option. This has been released in v0.12.0 as well.
While the work in that PR overlaps with the work you have done in this feature PR, we do see it as a potentially complementary feature. We would like to add the CLI flag --sort
that can provide the functionality of the config value as well.
Would you like to rebase your feature branch and integrate the functionality from #124 with the CLI flag work you have done? Or would you like to have one us take on the work of introducing the --sort
flag?
No pressure either way. We wanted to ask you first as you have put in this contribution and we appreciate your work. Thanks again!
@clok sounds good. I should be able to get this updated within the next day or so once I wrap up a couple things with work. |
@sanderblue thats great! Totally understand the delay. No worries there. Don't hesitate to reach out if you have questions or feedback. This work will resolve #112 as well. Thanks! |
I've rebased and will be working to get this working soon with the latest updates. |
c71fd01
to
0ad8bbb
Compare
0ad8bbb
to
2f00715
Compare
--sort-by-version
flag --sort [TYPE]
flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thanks again for keeping on this, following up on the feedback and updating after the config based PR came through. 🥇
If you could update the README with the updated CLI help output in the "CLI Usage" section, that would be awesome. Just helps us keep the repo up-to-date.
Leaving an "Approve" on this as I don't see it as critically blocking and I am happy to pick up that edit in the end.
@@ -308,7 +308,7 @@ func (config *Config) Convert(ctx *CLIContext) *chglog.Config { | |||
Options: &chglog.Options{ | |||
NextTag: ctx.NextTag, | |||
TagFilterPattern: ctx.TagFilterPattern, | |||
Sort: opts.Sort, | |||
Sort: orValue(ctx.Sort, opts.Sort), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. This was what I was looking for. 😀
@clok updated the CLI usage section with the new |
This has been releases as a part of the v0.14.0 release. Thank you for your contribution! |
What does this do / why do we need it?
First off, thank you for creating an awesome tool. We're using
git-chglog
in many open source repositories at New Relic and we would like to continue doing so.The PR introduces sorting tags by version number instead of sorting by the date of tag creation. Users can still sort by date by passing the flag--sort-by-date
. Using--sort-by-date
will perform the original behavior of thegit-chglog
command.Per request to integrate with the latest configuration updates from #124 (nice addition @ldelossa 🙂 ), this pull request introduces sorting tags by semver version using the
--sort [TYPE]
flag whereTYPE
is eitherdate
orsemver
. Sort by date is still default behavior.Previous reasoning behind the idea:
Since we support multiple major release branches of a repository, our CHANGELOG gets mangled when we release v1.x and then release an update for v2.x. Essentially the v1.x commits get combined with the v2.x commits in the CHANGELOG and requires manual editing that can be cumbersome with every new release we create. Sorting the tags by version number fixes this issue.
Give it a test drive:
This will build the binaries for supported architectures located in the
./bin
directory- e.g../bin/{arch}/git-chglog
(replace{arch}
withdarwin
, etc)How this PR fixes the problem?
Sorting the tags by version number ensures
git-chglog
selects the correct previous tag to compare to the new tag.Current hypothetical ordering for a CHANGELOG might look like this:
This is because the diff that's being checked is
github.com/user/repo/compare/v1.1.1...v2.1.0
, but we need this to begithub.com/user/repo/compare/v2.0.0...v2.1.0
for the latest release in the example above.This PR introduces ordering for a CHANGELOG that looks like this:
This ensures the correct previous tag is selected for comparison to create the CHANGELOG entries.
What should your reviewer look out for in this PR?
This PR migrates this project from
dep
to Go modules. Thevendor
directory is no longer needed.Check lists
Which issue(s) does this PR fix?
Resolves: #74
Resolves: #112