-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Respect --force option for config/master.key #31957
Conversation
This is similar to rails#30700 which ensures the `--quiet` option of `rails new` is respected by the `MasterKeyGenerator` (missing from rails#30067). Before this commit, running `rails new app --force` would still prompt the user what to do with the conflict in `config/master.key`: ``` … identical config/locales/en.yml conflict config/master.key Overwrite /Users/claudiob/Desktop/pizza/config/master.key? (enter "h" for help) [Ynaqdh] ``` After this commit, `config/master.key` is overwritten: ``` … identical config/locales/en.yml force config/master.key append .gitignore ``` The newly added test generates an app and then generates it again with `--force`. Without this commit, the test would just wait forever for user input.
My suggestion would be to backport this to 5.2 as well. |
Respect --force option for config/master.key
Backported 74976e8 |
Mmmh @y-yagi now that I think about it, I see another issue related to this code. On one hand, it's true that I can see two solutions here:
or
def add_credentials_file_silently(template = nil)
unless credentials.content_path.exist?
credentials.write(credentials_template)
end
end What's your opinion? |
Thanks. I think the first solution is good. |
@y-yagi That sounds good. Go for it! 🏃 |
See rails#31957 (comment) The purpose of `--force` is not to have any prompt whether a file should be kept or overwritten. In general, all existing files should be overwritten. However, `config/master.key` is special because it is git-ignored, and overwriting it will cause the app not to run (since there won't be a way to decrypt the credentials). As a result, it's probably better to keep the existing config/master.key.
This is similar to #30700 which ensures the
--quiet
option ofrails new
is respected by theMasterKeyGenerator
(missing from #30067).Before this commit, running
rails new app --force
would still prompt the user what to do with the conflict inconfig/master.key
:After this commit,
config/master.key
is overwritten:The newly added test generates an app and then generates it again with
--force
. Without this commit, the test would just wait forever for user input.