Skip to content

--front-matter raises a NoMethodError for #to_yaml #962

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

Closed
jorgecarleitao opened this issue May 14, 2021 · 9 comments · Fixed by #963
Closed

--front-matter raises a NoMethodError for #to_yaml #962

jorgecarleitao opened this issue May 14, 2021 · 9 comments · Fixed by #963
Labels

Comments

@jorgecarleitao
Copy link

Describe the bug

When the changelog is created with a section front-matter=For older versions, see X, the output is

For older versions, see X# Changelog

i.e. there is no break line.

Is there a way to fix this as a user, or is it a bug?

@olleolleolle
Copy link
Collaborator

olleolleolle commented May 14, 2021

I would call it a bug, one which perhaps occurs for users that do not use the Rake task way of configuration - since there they have the full power of Ruby - they can add "\n" as they want to in their configuration line.

Are you using the configuration file way of configuring, here? (Asking to narrow down where to try finding the current behavior.)

Proposed Workaround 1: use a Rakefile and configure the task with Rake.

Update:

         opts.on("--front-matter JSON", "Add YAML front matter. Formatted as JSON because it's easier to add on the command line.") do |v|
          options[:frontmatter] = "#{JSON.parse(v).to_yaml}---\n"
        end

By formatting your test as a JSON string, you can add newlines.

But, this makes me thing of YAML front-matter: it's not just a text section, it has a specific meaning. It is meant to be a section for YAML configuration of the Markdown document. Metadata, information that can't be inside the document.

https://jekyllrb.com/docs/front-matter/

@jorgecarleitao
Copy link
Author

I am using the docker image and the configuration file .github_changelog_generator.

@olleolleolle
Copy link
Collaborator

@jorgecarleitao

An example input in the field would be something like

github_changelog_generator --front-matter '{"hello":"world"}'

which would turn into a YAML preamble aka front-matter.

If you try adding that single option as a CLI configuration option, does that generate a YAML frontmatter?

@jorgecarleitao
Copy link
Author

Thanks a lot @olleolleolle for your fast reply and help.

So, that seems to raise an error instead:

/usr/local/bundle/gems/github_changelog_generator-1.16.2/lib/github_changelog_generator/argv_parser.rb:76:in `block (2 levels) in parser': undefined method `to_yaml' for {"hello"=>"world"}:Hash (NoMethodError)
Did you mean?  to_a

command:

docker run -it --rm -e CHANGELOG_GITHUB_TOKEN=$CHANGELOG_GITHUB_TOKEN \
    -v "$(pwd)":/usr/local/src/your-app \
    githubchangeloggenerator/github-changelog-generator \
    --user apache \
    --project arrow-rs \
    --since-commit 2021-04-20 \
    --future-release 4.0.1 \
    --front-matter '{"hello":"world"}'

@olleolleolle
Copy link
Collaborator

olleolleolle commented May 14, 2021

@jorgecarleitao That's good news, since we can change the to_yaml to a YAML.generate implementation instead.

Update: The problem was just that the YAML library was not yet loaded.

@olleolleolle olleolleolle changed the title front-matter does not allow break lines? --front-matter raises a NoMethodError for #to_yaml May 14, 2021
@olleolleolle
Copy link
Collaborator

The bug fix has been released as v1.16.3.

@jorgecarleitao
Copy link
Author

wow, thank you so much for such a quick reaction, fix and release ❤️

Much appreciated, @olleolleolle !

@jorgecarleitao
Copy link
Author

Does this release triggered the release of a new docker image?

@olleolleolle
Copy link
Collaborator

@jorgecarleitao I don't think that it does. I don't know exactly how that works, though!

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