git2consul icon indicating copy to clipboard operation
git2consul copied to clipboard

Leading whitespace is removed

Open alexdawes opened this issue 8 years ago • 3 comments

From what I can tell, git2consul drops leading whitespace. I was using this to mirror a repo full of yaml files, but trying to parse the yaml from consul was failing. Tracked this to a yaml file of the form

  - foo: Foo
  - bar: Bar

However, the file appearing in git2consul looked like:

- foo: Foo
  - bar: Bar

The former is valid yaml, whilst the latter is not. Changing to

---
  - foo: Foo
  - bar: Bar

worked around the issue, but ideally we would not need to do this (even though IMO its a better syntax).

Is the removal of leading whitespace by design?

alexdawes avatar Jun 13 '17 11:06 alexdawes

Offending line seems to be https://github.com/Cimpress-MCP/git2consul/blob/master/lib/consul/index.js#L245.

      body = body ? body.trim() : '';

Any chance we can remove the trim and do just:

      body = body || '';

alexdawes avatar Jun 13 '17 12:06 alexdawes

Also https://github.com/Cimpress-MCP/git2consul/blob/master/lib/consul/index.js#L183 and https://github.com/Cimpress-MCP/git2consul/blob/master/lib/consul/index.js#L230 I guess.

alexdawes avatar Jun 13 '17 12:06 alexdawes

https://github.com/Cimpress-MCP/git2consul/pull/151

alexdawes avatar Jun 13 '17 14:06 alexdawes