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
MODULES-1821 support empty sections #274
Merged
Lavinia-Dan
merged 21 commits into
puppetlabs:master
from
cjepeway:MODULES-1821-empty-sections
Oct 8, 2018
Merged
MODULES-1821 support empty sections #274
Lavinia-Dan
merged 21 commits into
puppetlabs:master
from
cjepeway:MODULES-1821-empty-sections
Oct 8, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Both AppVeyor and Travis CI are bombing on how multi-line strings are indented. I'll clean those up once I get some feedback on the fixes. I'd suggest cleaning up all the expected values to be transformations on |
What ever happened with this? |
(MODULE-1821) There are quite a few tests of 'if no sections exist', so group them into their own context. The plan is to start on supporting empty sections using this context.
(MODULES-1821) Add surrounding brackets to expected value when testing that a empty section (one without any settings) can be added to an empty file.
A resource can now have a nil setting and value; this indicates a section that has no settings, and hence is empty. Also, the global setting always exists, even for empty files. Finally, this changes how the global section is considered empty: since the global section has no header, we can't call it empty when its starting & ending lines are zero. That, in fact, is when it includes a single setting or comment. Instead, we consider the global section empty whenever it's new. (Apologies, I'm trying to stage these git commits in a logical way, but I'm working with changes made in an SVN repo that were much more haphazard. Until I stash the changes I have yet to commit, I won't know whether these committed changes pass the tests. So, this commit may break tests. We'll see.)
(MODULES-1821) The committed code doesn't yet include fixes for the (kinda annoying) empty blank line that the module puts into an empty or non-existent file when it adds a module. So, update the test to expect that extra newline.
(MODULES-1821) These tests of working with empty files now expect that an initial blank line won't be added when adding a new section. Strictly speaking, the following commits have nothing to do with MODULES-1821. But, well, that's another thing I fixed, and so I'm committing these changes, too. They can be broken apart use the tag I previously created, or so I hope.
Stop adding that superfluous intial blank line when the section or setting is added to an empty or non-existant file.
Test whether an empty section can be added to existing sections.
Rubocop is unhappy with "and" in boolean expressions, so switch to && so it'll settle down.
(MODULES-1821) Add a test that a new setting can be added to an empty section (one with only a [section] line).
(MODULES-1821) When adding a setting to an empty, pre-existing section (one with just a [section] header), the header wasn't written out. This commit is meant to fix that problem.
Prior to supporting empty sections, when the the final line in a section was removed by deleting its sole setting, the section's header was also removed, thereby deleting the section. For now, restore that behavior to preserve backwards compatibility. There may come a time when, in the world of empty sections, deleting such a setting should *not* cause the section header to be deleted. That's a debate for the future.
Lavinia-Dan
force-pushed
the
MODULES-1821-empty-sections
branch
from
October 8, 2018 07:54
065594c
to
52a5789
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think I've fixed the problem of not being able to specify bare [sections], those without any settings in them. This issue was reported as MODULES-1821 some years back.
I also think I've fixed the problem of the stray newline that shows up at the beginning of an .ini file when an ini_setting is added to an empty file. I believe I have structured the commits in a way that that fix doesn't need to be merged at the same time as the empty section fix.
I haven't added any acceptance tests, as I don't have vagrant or virtualbox installed.
I'm quite willing to rework this pull request however you'd like, if you think these fixes or something like them would be accepted into the official repo. I'll need to do right by my day job, though, so any re-work of this pull request might take a week or two.
Let me know what y'all think.