-
Notifications
You must be signed in to change notification settings - Fork 64
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
Use $EDITOR as text editor fallback #184
Changes from 2 commits
9b1c9cb
b37d92e
4241771
2ad213b
759f3c3
e520735
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ def git_root_dir | |
end | ||
|
||
def git_editor_command | ||
@git_editor_command ||= GitReflow::Config.get('core.editor') | ||
GitReflow::Config.get('core.editor') || ENV['EDITOR'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, didn't know that constant existed already :) |
||
end | ||
|
||
def remote_user | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,23 @@ module Gitacular | |
it { expect{ subject }.to have_run_command_silently "git rev-parse --show-toplevel" } | ||
end | ||
|
||
describe '.git_editor_command' do | ||
subject { Gitacular.git_editor_command } | ||
before { allow(ENV).to receive(:[]).with('EDITOR').and_return 'vim' } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather see this set explicitly to avoid issues this may pose with the CI: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
|
||
it 'defaults to GitReflow config' do | ||
allow(GitReflow::Config).to receive(:get).with('core.editor').and_return 'nano' | ||
|
||
expect(subject).to eq 'nano' | ||
end | ||
|
||
it 'falls back to the environment variable $EDITOR' do | ||
allow(GitReflow::Config).to receive(:get).with('core.editor').and_return nil | ||
|
||
expect(subject).to eq 'vim' | ||
end | ||
end | ||
|
||
describe ".remote_user" do | ||
subject { Gitacular.remote_user } | ||
|
||
|
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.
Removed the memoize because
GitReflow::Config#get
already seems to cache the "slow" code, and I got wrongly memoized values in the twoit
blocks in the spec