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

[FEATURE] Read-only rendered files #51

Open
thecaralice opened this issue Jan 30, 2021 · 5 comments
Open

[FEATURE] Read-only rendered files #51

thecaralice opened this issue Jan 30, 2021 · 5 comments

Comments

@thecaralice
Copy link

thecaralice commented Jan 30, 2021

Is your feature request related to a problem? Please describe.
Sometimes I forget about dotter and edit files in place (e.g. ~/.config/sway/config instead of ~/.dotter/sway) This causes issues when deploying dotfiles.

Describe the solution you'd like
Make the rendered files read-only (like chmod a-w)

Describe alternatives you've considered
None

Additional context
None

@SuperCuber
Copy link
Owner

So instead of having:

  • edit target file
  • everything "works"
  • dotter warns you next time you run it and suggests --force

You'd like

  • edit target file
  • editor refuses to save

I think it would be a better user experience in that case, but right now Dotter copies the permissions exactly as they are on the source file and I don't want to change it by default. Also, editing the target file is sometimes useful for quickly testing something or for GUI applications that actually edit it when you modify their settings.

I'm open to implementing this as a flag though.
Maybe it's about time we had a dotter.toml for these kinds of settings...

@plmwd
Copy link

plmwd commented Nov 9, 2021

Would it be possible to not change the permissions of the files, but add the ability to automatically merge changes before deploying? There could also be a merge command. Dotter can print an error if the file has templates. Even better, if the changes don't touch template code, then do the merge. I'm not sure how you would implement this, though. Although, I'm open to helping out after the semester ends.

@SuperCuber
Copy link
Owner

Dotter can print an error if the file has templates.

This is actually the only interesting case - in case of a symlink, the filesystem already keeps both locations in sync since they actually are the same file on disk, so nothing needs to be done.

I'm not sure on how to implement this either :P

@kakawait
Copy link
Contributor

kakawait commented Jan 2, 2022

Maybe one possibility is to pre-render template in temp/cache folder then diff the pre-render with the target?

@SuperCuber
Copy link
Owner

SuperCuber commented Jan 2, 2022

Maybe one possibility is to pre-render template in temp/cache folder then diff the pre-render with the target?

It seems like a good idea and a pretty simple solution to the problem - this will also help you decide if you want to --force or not


Note to self: This could be done in this code - stick a print_template_diff in case of Changed

Note2: Actually this is more complicated. The Changed comparison is between cache (how I left the file) and target, but diff is between rendered and target... :/ my brain hurts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants