Skip to content
Browse files

Merge pull request #1031 from sauliusgrigaitis/master

Allow to customize username in revision log via local_user variable
  • Loading branch information...
2 parents bb2ed22 + a0bebaf commit 6a77aca895aab52389df662b1515b76e2f91b88f @leehambley leehambley committed
Showing with 34 additions and 12 deletions.
  1. +1 −0 CHANGELOG.md
  2. +2 −0 lib/capistrano/defaults.rb
  3. +1 −1 lib/capistrano/dsl.rb
  4. +30 −0 spec/integration/dsl_spec.rb
  5. +0 −11 spec/lib/capistrano/dsl_spec.rb
View
1 CHANGELOG.md
@@ -10,6 +10,7 @@ https://github.com/capistrano/capistrano/compare/v3.2.1...HEAD
* Fixed compatibility with FreeBSD tar (@robbertkl)
* Minor Changes
+ * Capistrano now allows to customize `local_user` for revision log. (@sauliusgrigaitis)
* Added tests for after/before hooks features (@juanibiapina, @miry)
* Improved the output of `cap --help`. (@mbrictson)
* Cucumber suite now runs on the latest version of Vagrant (@tpett)
View
2 lib/capistrano/defaults.rb
@@ -10,3 +10,5 @@
set :log_level, :debug
set :pty, false
+
+set :local_user, -> { Etc.getlogin }
View
2 lib/capistrano/dsl.rb
@@ -42,7 +42,7 @@ def rollback_log_message
end
def local_user
- Etc.getlogin
+ fetch(:local_user)
end
def lock(locked_version)
View
30 spec/integration/dsl_spec.rb
@@ -488,4 +488,34 @@
end
end
end
+
+ describe 'local_user' do
+ before do
+ dsl.set :local_user, -> { Etc.getlogin }
+ end
+
+ describe 'fetching local_user' do
+ subject { dsl.local_user }
+
+ context 'where a local_user is not set' do
+ before do
+ Etc.expects(:getlogin).returns('login')
+ end
+
+ it 'returns the login name' do
+ expect(subject.to_s).to eq 'login'
+ end
+ end
+
+ context 'where a local_user is set' do
+ before do
+ dsl.set(:local_user, -> { 'custom login' })
+ end
+
+ it 'returns the custom name' do
+ expect(subject.to_s).to eq 'custom login'
+ end
+ end
+ end
+ end
end
View
11 spec/lib/capistrano/dsl_spec.rb
@@ -48,16 +48,5 @@ class DummyDSL
dsl.sudo(:my, :command)
end
end
-
- describe '#local_user' do
-
- before do
- Etc.expects(:getlogin)
- end
-
- it 'delegates to Etc#getlogin' do
- dsl.local_user
- end
- end
end
end

0 comments on commit 6a77aca

Please sign in to comment.
Something went wrong with that request. Please try again.