Skip to content
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

Merged
merged 6 commits into from
Jun 7, 2016
Merged

Use $EDITOR as text editor fallback #184

merged 6 commits into from
Jun 7, 2016

Conversation

timraasveld
Copy link
Contributor

@timraasveld timraasveld commented Jun 2, 2016

If no editor is set up specifically for gitreflow, in its current state it would just skip editing the PR message when using git-reflow review, which I think is never desirable.

This makes it fall back to $EDITOR which is set up on most unixy systems, and which I believe git also uses for commit messages

@timraasveld timraasveld changed the title Use $EDITOR as editor fallback Use $EDITOR as text editor fallback Jun 2, 2016
@@ -10,7 +10,7 @@ def git_root_dir
end

def git_editor_command
@git_editor_command ||= GitReflow::Config.get('core.editor')
Copy link
Contributor Author

@timraasveld timraasveld Jun 2, 2016

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 two it blocks in the spec

@timraasveld
Copy link
Contributor Author

Don't understand why the Circle tests suddenly fail after my last commit, which only removes an unneccesary ENV mock.

Could someone with permissions on Circle trigger a rebuild without cache, please?

@@ -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']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use GitReflow::DEFAULT_EDITOR instead of ENV['EDITOR']

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, didn't know that constant existed already :)

@@ -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' }
Copy link
Collaborator

Choose a reason for hiding this comment

The 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: ENV['EDITOR'] = 'vim'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@codenamev
Copy link
Collaborator

One last comment, and this LGTM. Thanks!

@timraasveld
Copy link
Contributor Author

I made GitReflow::DEFAULT_EDITOR a method instead of constant, because the constant caused mocking of ENV to be useless (the constant would be defined based on the actual ENV value BEFORE the mocking could took place)

@timraasveld
Copy link
Contributor Author

Failing spec is a one-second timing mismatch, rebuild should fix it.

@codenamev
Copy link
Collaborator

Awesome, nice work! 👍

@codenamev codenamev merged commit 6ea9a25 into reenhanced:master Jun 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants