Skip to content

Add option to show selected labels in the issue line #418

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
merged 1 commit into from
Oct 26, 2016
Merged

Conversation

aih
Copy link
Contributor

@aih aih commented Sep 23, 2016

This adds an option, --issue-line-labels, which allows the user to list the specified Github labels, in brackets, next to each issue.

For example, when issue #367 of this repository is closed, the Changelog for that issue, with option --issue-line-labels=ALL will look like this:

Selected labels can be specified in the option:
--issue-line-labels=first-timers-only will generate the following line:

Related to #316

@olleolleolle
Copy link
Collaborator

Hi Ari!

Glad you wanted to add a feature to this tool.

To make this PR mergeable, you need to rebase it on top of master. At this point, master has OctoKit in it.

  • To make the feature more useful to users, it needs more description, and I suppose the Description field of this PR is a good place to begin. Add usage and a few examples of what it looks like.
  • The name of the new option has "show" in it, which does not fit perfectly with the list of label names that are to be filtered-and-suffixed onto the issue line. ("Show" implies a Boolean "on" setting.) Perhaps something like --issue-line-labels=First-Timers-Only,Documentation,CssChanges?

It's awesome to see new people modify this to their needs. Can you find a way to make the above happen? If not, would you want me to make the changes, carrying your PR into master?

@aih
Copy link
Contributor Author

aih commented Oct 4, 2016

I've updated the code and rebased on top of the latest Master commit. I can also update the wiki page to document this option once the pull request is merged. I've found this to be a very flexible and helpful utility for creating Changelogs.
I have integrated it with Grunt.js and convert the .md to html for my application's webpage.

@crtrott
Copy link

crtrott commented Oct 26, 2016

The second feature I was thinking of as missing after using the tool for the first time 👍

Copy link
Collaborator

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

Cool!

I made some edit notes, so that the change can be merged.

@@ -205,6 +208,7 @@ def self.default_options
enhancement_labels: %w(enhancement Enhancement),
bug_labels: %w(bug Bug),
exclude_labels: %w(duplicate question invalid wontfix Duplicate Question Invalid Wontfix),
issue_line_labels: [],
Copy link
Collaborator

Choose a reason for hiding this comment

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

end
labels_string = labels.map { |label| " \[[#{label['name']}](#{label['url'].sub! 'api.github.com/repos', 'github.com'})\]" }.join("")
line = "#{line}#{labels_string}"
line
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would be more comfortable with a function that only calculated the labels string from the issue data:

def line_labels_for(issue)
  labels = if options[:issue_line_labels] == ["ALL"]
             issue["labels"]
           else
             issue["labels"].select { |label| options[:issue_line_labels].include?(label["name"]) }
           end
  labels.map { |label| " \[[#{label['name']}](#{label['url'].sub('api.github.com/repos', 'github.com')})\]" }.join("")
end

This could be used like

if options[:issue_line_labels].present?
  title_with_number = "#{title_with_number}{line_labels_for(issue)}"
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@olleolleolle, this all works for me. Thanks for making the code changes (I'm not a Ruby developer, but this project has been very useful). I've updated the code for this issue and rebased.

@olleolleolle
Copy link
Collaborator

@aih In my changes, I used ActiveSupport core_ext methods. That's not prevalent around all of the code, but it's there.

@olleolleolle
Copy link
Collaborator

Thanks, @aih! This looks grand. I'll merge it, pending all the builds. Yay!

@olleolleolle olleolleolle merged commit 9b0d417 into github-changelog-generator:master Oct 26, 2016
@olleolleolle
Copy link
Collaborator

:party:

@skywinder
Copy link
Member

Great addition! Thanks! 👍

end
labels.map { |label| " \[[#{label['name']}](#{label['url'].sub('api.github.com/repos', 'github.com')})\]" }.join("")
end

Copy link
Member

Choose a reason for hiding this comment

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

@aih can you add tests to covers cases with new method?

Copy link
Member

@skywinder skywinder left a comment

Choose a reason for hiding this comment

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

Everything is great, just want to mention, that line_labels_for is not covered by tests yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants