timbertson / dhall-render

Render multiple files from dhall expressions
BSD Zero Clause License
18 stars 7 forks source link

Fix regex for parentheses workaround #12

Closed ckumar1 closed 3 years ago

ckumar1 commented 3 years ago

Fixes an issue where the parentheses workaround for https://github.com/dhall-lang/dhall-haskell/issues/1672 was broken. After the dhall freeze step happens here, the remote import in contents actually gets broken into two lines and looks like this for classic:

let groups =
      https://raw.githubusercontent.com/zendesk/config-service-data/3b1d6774838796c47908710bf8dde95a67308ea5/generated/dhall/data/shared_env_groups/package.dhall using ./github-headers.dhall
        sha256:54b2af133f73f77b919d53229c61c3d9288096207e796c27229b7cd653824a14

The following regex addresses this case, but I am open to workshopping it to be more robust if we know what other forms this could take.

timbertson commented 3 years ago

Given that it's been working for a while, I suspect the newline is only introduced if your import hits a certain line length. Or possibly it depends on dhall version. I've tweaked this a little bit to support both, and because I don't trust regexes as far as I can throw them, I've added a test case too. Thanks for starting this!