Skip to content
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

Lock command removes comments from configuration file #170

Open
daniel-brosche opened this issue Jun 26, 2018 · 8 comments
Open

Lock command removes comments from configuration file #170

daniel-brosche opened this issue Jun 26, 2018 · 8 comments
Assignees
Labels

Comments

@daniel-brosche
Copy link
Collaborator

A given gitman.yml like:

location: demo
sources:
# gitman sources part 1
- name: gitman_1
  repo: https://github.com/jacebrowning/gitman-demo
  rev: example-branch

# --------------------------------------------------- 
# Here some more documentation about the dependencies
# ---------------------------------------------------

# gitman sources part 2
- name: gitman_2
  repo: https://github.com/jacebrowning/gitman-demo
  rev: example-tag
  

will be transformed after a lock operation to:

location: demo
sources:
- name: gitman_1
  type: git
  repo: https://github.com/jacebrowning/gitman-demo
  sparse_paths:
  -
  rev: example-branch
  link:
  scripts:
  -
- name: gitman_2
  type: git
  repo: https://github.com/jacebrowning/gitman-demo
  sparse_paths:
  -
  rev: example-tag
  link:
  scripts:
  -
sources_locked:
- name: gitman_1
  type: git
  repo: https://github.com/jacebrowning/gitman-demo
  sparse_paths:
  -
  rev: 1de84ca1d315f81b035cd7b0ecf87ca2025cdacd
  link:
  scripts:
  -
- name: gitman_2
  type: git
  repo: https://github.com/jacebrowning/gitman-demo
  sparse_paths:
  -
  rev: 7bd138fe7359561a8c2ff9d195dff238794ccc04
  link:
  scripts:
  -

Unfortunately, most importantly the comments are removed and secondly the structure of the gitman.yml will be changed.
In this matter, all available but unused parameters for an source entry will be added.

I see the benefit to keep the comments and also not to spoil the gitman.yml with unused settings (at least for the sources section.
Maybe it is an approach to seperate the source_locked section in a seperate file.

@jacebrowning
Copy link
Owner

jacebrowning commented Jun 26, 2018

What are your use cases for comments?

@daniel-brosche
Copy link
Collaborator Author

daniel-brosche commented Jun 27, 2018

The basic use case is that I have a gitman.yml with a bunch of source dependencies.
A couple of them can be logicaly grouped and this group information (why this imports are needed, which imports are closely related, which should be updated together) has been documented directly inside of the gitman.yml.
Because of comments are an integral part of yml file format it would be nice if this can be used to document the gitman.yml contents.

@jacebrowning
Copy link
Owner

This would require using a different YAML library (https://stackoverflow.com/a/27103244/429533) in the upstream YAML library. I might consier this down the road, but this would be a pretty major change.

We could add a description and/or comment field. I think I'd like to wait for more people to ask for this.

In this matter, all available but unused parameters for an source entry will be added.

I would eventually like to address this in the upstream YAML library.

@daniel-brosche
Copy link
Collaborator Author

I do understand the impact. Maybe another solution is not to modify the gitman.yml and store the sources_locked section in a seperate file.
I think it is possible to add this as a seperate feature.
One possible solution could be to add a new optional argument to pass a filepath or just an option to instruct that source_locked will be stored in a file by convention like gitman.lock.yml.
Over this way the commands lock and install could store and load the content from a seperate file and leaf the main gitman.yml untouched.
As a result the main gitman.yml will not be rewritten by this operations so that the comments and the overall structure will be preserved.

An extension of this could be to use the untouched gitman.yml as a template and just replace the rev values so that the same layout will be used for the gitman.lock.yml file.
But in my case the most important thing is to preserve the main gitman.yml file.

Just some ideas...

@jacebrowning
Copy link
Owner

I agree that this would be nicer and if I were building this again today, I think I would have opted for a separate lock file.

Let's consider this a feature request for 2.0. 😄

@daniel-brosche
Copy link
Collaborator Author

Could we tag this to group feature request for gitman 2.0?

@jacebrowning jacebrowning added this to the v2.0 milestone Jun 28, 2018
@jacebrowning
Copy link
Owner

I'm working on rewriting the underlying YAML library with the intention of being able to preserve comments: https://github.com/jacebrowning/datafiles

@jacebrowning
Copy link
Owner

YORM has been replaced with datafiles in the 2.0 beta releases, but we're not yet able to attach comments to list items: jacebrowning/datafiles#171

@jacebrowning jacebrowning removed this from the v2.0 milestone Dec 23, 2020
@jacebrowning jacebrowning added bug and removed feature labels Mar 11, 2022
@jacebrowning jacebrowning changed the title gitman lock does remove comments and manipulate structure of gitman.yml Lock command removes comments from configuration file Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants