bazel-deps icon indicating copy to clipboard operation
bazel-deps copied to clipboard

format-deps and add-dep commands strip out comments

Open vmax opened this issue 6 years ago • 2 comments

This:

options:
  # one comment
  languages: [ "java" ]
  licenses: [ "permissive" ]
  resolvers: 
    - id: "mavencentral"
      type: "default"
      url: https://repo.maven.apache.org/maven2/
  thirdPartyDirectory: "third_party/maven/"
  transitivity: runtime_deps
  versionConflictPolicy: highest

dependencies:
  # another one
  org.slf4j:
    slf4j-simple:
      lang: java
      version: "1.7.25"

turns into this:

options:
  languages: [ "java" ]
  licenses: [ "permissive" ]
  resolvers: 
    - id: "mavencentral"
      type: "default"
      url: https://repo.maven.apache.org/maven2/
  thirdPartyDirectory: "third_party/maven/"
  transitivity: runtime_deps
  versionConflictPolicy: highest

dependencies:
  org.slf4j:
    slf4j-simple:
      lang: java
      version: "1.7.25"

Could you please either fix the behaviour or warn that comments were lost?

vmax avatar Mar 24 '18 13:03 vmax

It’s hard to fix because the parser we are using strips the comments.

johnynek avatar Mar 24 '18 15:03 johnynek

Related to #15

If you know a yaml parser that can address these two issues, let me know. Yaml is kind of a big spec so while it would be easy to parse our current subset it would not be easy to parse in general.

A work around could be to add explicit comment nodes at points. Kind of junky, but it would lift the comment to a logical level where the parse won’t lose it.

johnynek avatar Mar 24 '18 15:03 johnynek