peru
peru copied to clipboard
edit_yaml does the nasty things to inline dict literals
Consider a module like this:
git module vim-bracketed-paste:
{url: "https://github.com/ConradIrwin/vim-bracketed-paste.git", reup: master}
That's valid YAML, using a JSON-style dict rather than a line-by-line dict. When we run reup, this happens:
git module vim-bracketed-paste:
{url: "https://github.com/conradirwin/vim-bracketed-paste.git", reup: master}
rev: 36779ba3b1af4b81fcba7b83095afe794a07b71a
That's gross, and furthermore it's not valid YAML. edit_yaml.py
is a shameful shameful hack. Because of the limitations of PyYAML, we're probably not going to be able to handle every case correctly. But as a stopgap, we could have reup parse the whole file before the edit, parse it again after the edit, and then at least guarantee that 1) the second parse works at all and 2) the in-memory result is what we expected given the edit we were trying to make. Failing either of those, reup will have to print an error and abort. It won't prevent corner cases where we get spacing and comments wrong, but at least it won't break the whole world.