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

Fix expansion of ~ in configured paths #1208

Merged
merged 6 commits into from
Jan 13, 2022

Conversation

shonfeder
Copy link
Contributor

@shonfeder shonfeder commented Jan 12, 2022

@Kukovec reported that ~ was not be expanded in configured paths correctly.
Indeed, this was an oversight on my part. I failed to correctly override
pureconfig's reader for Path and File types. This PR fixes that mistake.

Followup to #1160

  • Tests added for any new code
  • Ran make fmt-fix (or had formatting run automatically on all files edited)
  • Entry added to UNRELEASED.md for any new functionality

@shonfeder shonfeder requested a review from Kukovec January 12, 2022 03:21
@konnov
Copy link
Collaborator

konnov commented Jan 12, 2022

It does not seem to work with the docker tests

@shonfeder shonfeder enabled auto-merge January 13, 2022 02:01
@shonfeder
Copy link
Contributor Author

integration tests on docker are fixed.

Copy link
Collaborator

@konnov konnov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much simpler than before. Nice!

object Converters {
// Provides implicit conversions used when deserializing into configurable values.
private object Converters {
import pureconfig.ConvertHelpers._

private def expandedFilePath(s: String): Path = {
Paths.get(if (s.startsWith("~")) s.replaceFirst("~", System.getProperty("user.home")) else s)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we check, whether a string is starting with "~" + File.separator. Otherwise, we would misinterpret strings like ~user1, which have a different meaning in shell.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. Had this configured for auto merge once approved.

yeah, the expansion is not strictly correct. But that’s not actually introduced in this PR: it’s just a continuation of the initial code from the outputManager.

I’ll address this in a follow up tho.

@shonfeder shonfeder merged commit 8b02d1d into unstable Jan 13, 2022
@shonfeder shonfeder deleted the shon/fix-config-tilde-expansion branch January 13, 2022 12:49
@apalache-bot apalache-bot mentioned this pull request Jan 17, 2022
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.

2 participants