Skip to content

Commit 8bb23e9

Browse files
Remind of credentials diff enrollment on edit
When users create a new app or `git clone` an existing app, they may not realize it is enrolled in decrypted diffing of credentials (or be aware of the feature). This commit adds a confirmation message when configuring the Git diff driver for credentials, to serve as a reminder. The message will be shown when running `bin/rails credentials:edit` for the first time after `rails new` or `git clone`. This commit also silences the enrollment confirmation message when creating a new app, to reduce noise.
1 parent 974de71 commit 8bb23e9

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

railties/lib/rails/commands/credentials/credentials_command/diffing.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def enroll_project_in_credentials_diffing
1313
gitattributes.write(GITATTRIBUTES_ENTRY, mode: "a")
1414

1515
say "Enrolled project in credentials file diffing!"
16-
say "Rails ensures the rails_credentials diff driver is set when running `#{executable(:edit)}`. See `#{executable(:help)}` for more."
16+
say ""
17+
say "Rails will configure the Git diff driver for credentials when running `#{executable(:edit)}`. See `#{executable(:help)}` for more information."
1718
end
1819
end
1920

@@ -43,6 +44,7 @@ def diffing_driver_configured?
4344

4445
def configure_diffing_driver
4546
system "git config diff.rails_credentials.textconv '#{executable(:diff)}'"
47+
say "Configured Git diff driver for credentials."
4648
end
4749

4850
def gitattributes

railties/lib/rails/generators/rails/app/app_generator.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ def credentials
185185
def credentials_diff_enroll
186186
return if options[:skip_decrypted_diffs] || options[:skip_git] || options[:dummy_app] || options[:pretend]
187187

188-
rails_command "credentials:diff --enroll", inline: true, shell: @generator.shell
188+
@generator.shell.mute do
189+
rails_command "credentials:diff --enroll", inline: true, shell: @generator.shell
190+
end
189191
end
190192

191193
def database_yml

railties/test/commands/credentials_test.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,14 @@ class Rails::Command::CredentialsCommandTest < ActiveSupport::TestCase
237237

238238
test "running edit after enrolling in diffing sets diff driver" do
239239
run_diff_command(enroll: true)
240-
run_edit_command
240+
241+
assert_match %r/git diff driver/i, run_edit_command
241242

242243
Dir.chdir(app_path) do
243244
assert_equal "bin/rails credentials:diff", `git config --get 'diff.rails_credentials.textconv'`.strip
244245
end
246+
247+
assert_no_match %r/git diff driver/i, run_edit_command
245248
end
246249

247250
test "diff from git diff left file" do

0 commit comments

Comments
 (0)