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

Give a proper message when trying to use an empty config file #1461

Merged
merged 8 commits into from May 7, 2022
Merged

Give a proper message when trying to use an empty config file #1461

merged 8 commits into from May 7, 2022

Conversation

jonakeys
Copy link
Contributor

@jonakeys jonakeys commented Apr 27, 2022

Hi, I'm new to making commits so all feedback is welcome. Of course I put in my best effort.

This code adds a check for an empty config file, as specified by the issue #1420 . If an empty file is found, the programs prints a message and uses the default config, so the user won't be hindered in doing what he tried to do.

I added a bdd test, but couldn't get it to work properly. The test can't seem to find the new 'empty_file.yaml' config I created. Hopefully someone can help me out here.

Checklist

  • I have read the contributing doc.
  • I have included a link to the relevant issue number.
  • I have checked to ensure there aren't other open pull requests
    for the same issue.
  • I have written new tests for these changes, as needed.

Copy link
Member

@micahellison micahellison left a comment

Choose a reason for hiding this comment

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

Welcome and thanks for the PR, @jonakeys. I had a slightly different intent for the behavior that I realize I hadn't made clear in the original issue: we still want jrnl to fail if the config can't be parsed, rather than falling back to the default config.

Also, the error message should appear when using a default config that's empty too. I added a test for that situation and fixed the other test so that you can take a test-driven approach to this if you'd like.

jrnl/install.py Outdated Show resolved Hide resolved
tests/bdd/features/config_file.feature Show resolved Hide resolved
jrnl/install.py Outdated Show resolved Hide resolved
@jonakeys
Copy link
Contributor Author

jonakeys commented May 1, 2022

Thanks for your welcoming words and suggestions! I solved the issues and committed the changes. Had to add a condition to the test, because it would always automatically insert a version number and then the file wouldn't be empty.

@wren wren added the bug Something isn't working label May 7, 2022
Copy link
Member

@wren wren left a comment

Choose a reason for hiding this comment

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

Looks great. Thank you!

@micahellison micahellison linked an issue May 7, 2022 that may be closed by this pull request
2 tasks
@wren wren merged commit 792f188 into jrnl-org:develop May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty config file leads to confusing error message
3 participants