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
Sanitize release name for umbrella projects #397
Sanitize release name for umbrella projects #397
Conversation
lib/mix/lib/releases/utils.ex
Outdated
"project_name" | ||
""" | ||
@spec to_underscore(String.t) :: String.t | ||
def to_underscore(text) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might make more sense to name this sanitize_name
, since the name doesn't really reflect what it does.
I think a better test here would be to create a project on the fly, build a release in it, and make sure it starts. This doubles as a test for the process of going from new project to release. I don't think it's necessary to check it in (it's a lot of bloat just to check that it reads the config properly, there is probably a much easier method for doing that much). |
It occurs to me that perhaps a better approach here would be to just quote the atom, rather than sanitize it. That said, we probably do want to perform some degree of sanitization, since the name is used in a variety of contexts, and it is possible something else might get screwed up with really weird names. So I think this is probably a good approach 👍 |
Just noticed that
I found the problem because I changed my project's name on Github and when cloning it the folder was the domain name. It looks like this is an edge case. It's still worth it to sanitize the name though. So for the test, I'll create a project and rename the folder before running distillery. Sounds good? |
Yeah I know Mix won't allow it, but like you said, the edge case is always possible, so it's worth it to sanitize. As for the test, sounds good! |
I've just pushed the changes based on your feedback. |
Hey @bitwalker, do you have any feedback on this? |
I've taken a different approach on this. Rather than guessing the app names based on directory, the init task now actually parses/evaluates the AST of the |
Yeah, sounds like a better approach 👍 |
The problem
I was checking adding Distillery to my umbrella project and the repository has the domain in the name, eg:
distillery.io
.From what I could grasp, for umbrella projects Distillery uses the folder name as release name.
When running
mix release.init
, for the given exampledistillery.io
the configuration is invalid and does not compile:Summary of changes
Sanitize the folder name allowing only letters, numbers and underscores, everything else is replaced by underscore.
I've extracted the sanitization logic to the
Utils
module.As for the test, I don't really like the setup but I'll wait for your feedback on that 👍
Checklist