-
Notifications
You must be signed in to change notification settings - Fork 73
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
Fix style_file() so it works for a vector of files from different directories #522
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It has no obvious pros, but the cons are: Can't style multiple files if they are not in the same directory (and need overhead to adapt with status quo to it) + the messages of styling only show the filename, not the path, which might be confusing.
61401b9
to
2414ddf
Compare
2414ddf
to
1a9a854
Compare
c3d8ba1
to
c442be2
Compare
c442be2
to
30dc4cd
Compare
…pending on whether unicode is available before comparing captured output (because ruler length depends on max(nchar(files), 0) which depends on path structure on plattform which is not stable.
Codecov Report
@@ Coverage Diff @@
## master #522 +/- ##
==========================================
- Coverage 90.18% 90.06% -0.13%
==========================================
Files 39 40 +1
Lines 1732 1741 +9
==========================================
+ Hits 1562 1568 +6
- Misses 170 173 +3
Continue to review full report at Codecov.
|
11cb46f
to
d5e92cb
Compare
…just the file name and we don't need to bother about dir() returning C:\\xyz on windows and file.path() returning C:/ ect.
c5d9e8c
to
edb5208
Compare
edb5208
to
0dba22d
Compare
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #521 by not changing working directory to directory where the file lays. The bug was long undetected because
setwd()
fails silently on a character vector withinwithr::with_dir()
and is particularly relevant for #467, e.g. when R files inR/
andtests/testthat
are staged simultaneously.Note that this is an API change in the sense that now, the path to the directory where the files lay are printed, not just the file names, which also affects the invisible return values of the stylers that contain the path.
Created on 2019-06-19 by the reprex package (v0.2.1)
This change has implications for testing also. To make a comparison with an exact expectation, in the tests, we temporarily change the working directory to keep file paths and ruler width (that depends on the path) identical on all platforms. See
?styler:::catch_style_file_output
. Testing for thecat()
outputs of the public API was refactored also in this PR.The new utility
rds_to_version()
can be used to convert rds objects to the old serialization format to ensure CI passing. They are introduced in this PR because this is a use case where we need to udpate current reference values. Closes #524.