Open olivroy opened 1 month ago
Snapshot files should already be written with consistent line ending, so if you're seeing problems that's definitely a bug.
Oh, okay! Cool.
But I am surprised to see it hasn't come up before...
The simple way to get this is simply to work with snapshots on mac and Windows and you start seeing some ghost diffs appear.
I thought this was a pure git problem:
Here is what I tried:
I still think it can be solved with using the correct git setting. If it is, it may be worth documenting it?
I always end up with this in the git pane.
then I stage them
It is especially annoying when working with usethis::pr_*()
functions as I need to do a manual step before proceeding.
It makes it hard to distinguish between snapshots that changed vs remained the same.
It's possible that testthat uses the unix line endings for all the text it generates but it's possible that pkgdown is producing OS-varying line endings. Regardless, testthat should automatically process snapshots to remove \r
.
I think I finally found a way to mitigate that. Using the Posix line ending option in .Rproj seems to work pretty well!
This is not the default option, but for some collaborative projects, it may be worth using. Also, using core.autocrlf = true git config is not a good idea (unless all collaborators have this setting, but there is no good way to do this)
use_git_config(scope = "project", "core.autocrlf" = "false")
Seems to work well now. But I am stuck with a .Rproj always in diff. https://github.com/rstudio/rstudio/issues/1929
If snapshots are updated on macOS vs Windows, a ghost snapshot file can show in the git pane.
I suspect this related to line-end. Could snapshot files be written in a platform independent way to ensure that git doesn't show modifications where there are none?
Or should that be managed per project in git config?