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

Fixed comment and uncomment functions in file.py #24620

Merged
merged 1 commit into from Jun 12, 2015

Conversation

Projects
None yet
6 participants
@twangboy
Contributor

twangboy commented Jun 12, 2015

comment and uncomment now use file.replace
-- Need someone to double check the regex stuff
Added comment/uncomment to the win_file.py
Tested with states

@twangboy twangboy added the Bug label Jun 12, 2015

@twangboy

This comment has been minimized.

Contributor

twangboy commented Jun 12, 2015

Yay! It passed lint!

@UtahDave UtahDave closed this Jun 12, 2015

@UtahDave UtahDave reopened this Jun 12, 2015

@twangboy

This comment has been minimized.

Contributor

twangboy commented Jun 12, 2015

Fixes #24215

UtahDave added a commit that referenced this pull request Jun 12, 2015

Merge pull request #24620 from twangboy/fix_24215
Fixed comment and uncomment functions in file.py

@UtahDave UtahDave merged commit 635121e into saltstack:2014.7 Jun 12, 2015

4 of 5 checks passed

default Merged build finished.
Details
jenkins/salt-pr-clone Salt PR - Clone Repository #6760 — SUCCESS
Details
jenkins/salt-pr-linode-cent7-n Salt PR - Linode CentOS 7 #571 — SUCCESS
Details
jenkins/salt-pr-lint-n Salt PR - Code Lint #6540 — SUCCESS
Details
jenkins/salt-pr-rs-ubuntu14.04-n Salt PR - RS Ubuntu 14 #6103 — SUCCESS
Details

@twangboy twangboy added this to the Be 4 milestone Jun 23, 2015

@twangboy twangboy self-assigned this Jun 23, 2015

@twangboy twangboy modified the milestones: 2015.5.2, Be 4 Jun 23, 2015

limit=regex.lstrip('^'),
backup=backup)
pattern = '^{0}{1}'.format(char, regex.lstrip('^').rstrip('$'))
repl = "{0}".format(regex.lstrip('^').rstrip('$'))

This comment has been minimized.

@mtorromeo

mtorromeo Jul 21, 2015

Contributor

This is completely wrong! You are replacing the matched pattern with the regex itself.
This can only work if you don't actually use a regular expression.

For example if you try to uncomment level = (warning|error) and the file contains # level = warning it will be replaced with level = (warning|error).

This comment has been minimized.

@twangboy

twangboy Jul 21, 2015

Contributor

@mtorromeo Thanks. I'll take a look at and see if I can figure out a better solution.

@miihael

This comment has been minimized.

Contributor

miihael commented Jul 31, 2015

The change is not backward compatible: new version does not recognize "[[:space:]]*" in the beginning, just after the comment char.
For example, if regex="this is commented line", the following would not be uncommented:
# this is commented line

@orymate

This comment has been minimized.

Contributor

orymate commented on salt/modules/file.py in d7a9999 Aug 5, 2015

This caused #25866 (it didn't even consider if matched string is not literally equal to the regex pattern).

This comment has been minimized.

Contributor

twangboy replied Aug 5, 2015

There were serious issues with this entire function for both comment and uncomment. Some of which were fixed here: #25685 and here: #26002

@twangboy twangboy deleted the twangboy:fix_24215 branch Feb 18, 2016

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