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

feat: diff source with destination on conflict #117

Merged

Conversation

ditsuke
Copy link
Contributor

@ditsuke ditsuke commented Mar 19, 2023

Fixes #91

Summary

  • Source and target are diff-ed when target is modified between deploys
  • Diffs are printed, when there are real conflicts.
  • In the absence of real conflicts, target is silently updated cutting down
    on false conflict errors.

Also silences warnings when source and destination don't
really conflict.
@SuperCuber
Copy link
Owner

SuperCuber commented Mar 20, 2023

Looking good! Only need to make the function public so it compiles.

Also, I would remove the info print with the .yellow, that info is already in the error.

@SuperCuber
Copy link
Owner

One more comment, it makes sense to me to do the diff the other way around. Say someone added a line to the template and you're displaying that you are skipping because of the line, I would expect that line to be green. Right now however it shows the difference that it will apply if a force is requested which kinda makes sense too.

Which one do you think is better? In any case, we should print something like

[ERROR] Updating template "test_in/file" -> "test_out/file" but target contents were changed. Skipping.
    Difference between expected and actual:
    //or
    Refusing to make the following change:
// diff here

@ditsuke
Copy link
Contributor Author

ditsuke commented Mar 21, 2023

Looking good! Only need to make the function public so it compiles.

Also, I would remove the info print with the .yellow, that info is already in the error.

Whoops missed staging that!

One more comment, it makes sense to me to do the diff the other way around. Say someone added a line to the template and you're displaying that you are skipping because of the line, I would expect that line to be green. Right now however it shows the difference that it will apply if a force is requested which kinda makes sense too.

Which one do you think is better? In any case, we should print something like

[ERROR] Updating template "test_in/file" -> "test_out/file" but target contents were changed. Skipping.
    Difference between expected and actual:
    //or
    Refusing to make the following change:
// diff here

That makes sense to me. I'll update the behavior

@ditsuke ditsuke force-pushed the feat/diff-source-dest-on-conflict branch from 996c681 to bd57602 Compare March 21, 2023 04:06
@ditsuke
Copy link
Contributor Author

ditsuke commented Mar 21, 2023

@SuperCuber

I've updated it to target -> source. Here's what it looks like now:

❯ ./dotter -v     
[ERROR] Updating template ".gitconfig" -> "/home/dt/.gitconfig" but target contents were changed. Skipping
[ INFO] Refusing because of the following changes in source: 
 19 | 19 | [gpg]
 20 |    |      program = /usr/bin/gpg
    | 20 |      program = /usr/bin/gpg2
[ERROR] Some files were skipped. To ignore errors and overwrite unexpected target files, use the --force flag.

src/actions.rs Outdated Show resolved Hide resolved
@SuperCuber SuperCuber merged commit 8d04348 into SuperCuber:master Mar 22, 2023
@SuperCuber
Copy link
Owner

Thanks for the contribution!

@ditsuke
Copy link
Contributor Author

ditsuke commented Mar 23, 2023

Thanks for accepting!

@ditsuke ditsuke deleted the feat/diff-source-dest-on-conflict branch April 18, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show difference between source and destination file
2 participants