Fix rubocop issues for some recently merged code
This commit is contained in:
@@ -12,7 +12,8 @@ class Homesick
|
|||||||
FileUtils.mkdir_p destination.dirname
|
FileUtils.mkdir_p destination.dirname
|
||||||
|
|
||||||
if destination.directory?
|
if destination.directory?
|
||||||
say_status :exist, destination.expand_path, :blue unless options[:quiet]
|
say_status :exist, destination.expand_path, :blue \
|
||||||
|
unless options[:quiet]
|
||||||
else
|
else
|
||||||
say_status 'git clone',
|
say_status 'git clone',
|
||||||
"#{repo} to #{destination.expand_path}",
|
"#{repo} to #{destination.expand_path}",
|
||||||
@@ -27,7 +28,8 @@ class Homesick
|
|||||||
|
|
||||||
inside path do
|
inside path do
|
||||||
if path.join('.git').exist?
|
if path.join('.git').exist?
|
||||||
say_status 'git init', 'already initialized', :blue unless options[:quiet]
|
say_status 'git init', 'already initialized', :blue \
|
||||||
|
unless options[:quiet]
|
||||||
else
|
else
|
||||||
say_status 'git init', '' unless options[:quiet]
|
say_status 'git init', '' unless options[:quiet]
|
||||||
system 'git init >/dev/null' unless options[:pretend]
|
system 'git init >/dev/null' unless options[:pretend]
|
||||||
@@ -40,7 +42,8 @@ class Homesick
|
|||||||
existing_remote = nil if existing_remote == ''
|
existing_remote = nil if existing_remote == ''
|
||||||
|
|
||||||
if existing_remote
|
if existing_remote
|
||||||
say_status 'git remote', "#{name} already exists", :blue unless options[:quiet]
|
say_status 'git remote', "#{name} already exists", :blue \
|
||||||
|
unless options[:quiet]
|
||||||
else
|
else
|
||||||
say_status 'git remote', "add #{name} #{url}" unless options[:quiet]
|
say_status 'git remote', "add #{name} #{url}" unless options[:quiet]
|
||||||
system "git remote add #{name} #{url}" unless options[:pretend]
|
system "git remote add #{name} #{url}" unless options[:pretend]
|
||||||
@@ -71,7 +74,8 @@ class Homesick
|
|||||||
def git_commit_all(config = {})
|
def git_commit_all(config = {})
|
||||||
say_status 'git commit all', '', :green unless options[:quiet]
|
say_status 'git commit all', '', :green unless options[:quiet]
|
||||||
if config[:message]
|
if config[:message]
|
||||||
system "git commit -a -m '#{config[:message]}'" unless options[:pretend]
|
system "git commit -a -m '#{config[:message]}'" \
|
||||||
|
unless options[:pretend]
|
||||||
else
|
else
|
||||||
system 'git commit -v -a' unless options[:pretend]
|
system 'git commit -v -a' unless options[:pretend]
|
||||||
end
|
end
|
||||||
@@ -97,7 +101,8 @@ class Homesick
|
|||||||
destination = Pathname.new(destination + source.basename)
|
destination = Pathname.new(destination + source.basename)
|
||||||
|
|
||||||
if destination.exist?
|
if destination.exist?
|
||||||
say_status :conflict, "#{destination} exists", :red unless options[:quiet]
|
say_status :conflict, "#{destination} exists", :red \
|
||||||
|
unless options[:quiet]
|
||||||
|
|
||||||
system "mv '#{source}' '#{destination}'" \
|
system "mv '#{source}' '#{destination}'" \
|
||||||
if (options[:force] ||
|
if (options[:force] ||
|
||||||
@@ -113,10 +118,12 @@ class Homesick
|
|||||||
target = Pathname.new(target)
|
target = Pathname.new(target)
|
||||||
|
|
||||||
if target.symlink?
|
if target.symlink?
|
||||||
say_status :unlink, "#{target.expand_path}", :green unless options[:quiet]
|
say_status :unlink, "#{target.expand_path}", :green \
|
||||||
|
unless options[:quiet]
|
||||||
FileUtils.rm_rf target
|
FileUtils.rm_rf target
|
||||||
else
|
else
|
||||||
say_status :conflict, "#{target} is not a symlink", :red unless options[:quiet]
|
say_status :conflict, "#{target} is not a symlink", :red \
|
||||||
|
unless options[:quiet]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -134,10 +141,12 @@ class Homesick
|
|||||||
target = Pathname.new(target)
|
target = Pathname.new(target)
|
||||||
|
|
||||||
if target.symlink?
|
if target.symlink?
|
||||||
say_status :unlink, "#{target.expand_path}", :green unless options[:quiet]
|
say_status :unlink, "#{target.expand_path}", :green \
|
||||||
|
unless options[:quiet]
|
||||||
FileUtils.rm_rf target
|
FileUtils.rm_rf target
|
||||||
else
|
else
|
||||||
say_status :conflict, "#{target} is not a symlink", :red unless options[:quiet]
|
say_status :conflict, "#{target} is not a symlink", :red \
|
||||||
|
unless options[:quiet]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -172,7 +181,8 @@ class Homesick
|
|||||||
def handle_symlink_action(action, source, destination)
|
def handle_symlink_action(action, source, destination)
|
||||||
case action
|
case action
|
||||||
when :identical
|
when :identical
|
||||||
say_status :identical, destination.expand_path, :blue unless options[:quiet]
|
say_status :identical, destination.expand_path, :blue \
|
||||||
|
unless options[:quiet]
|
||||||
when :symlink_conflict
|
when :symlink_conflict
|
||||||
say_status :conflict,
|
say_status :conflict,
|
||||||
"#{destination} exists and points to " \
|
"#{destination} exists and points to " \
|
||||||
@@ -181,7 +191,8 @@ class Homesick
|
|||||||
|
|
||||||
system "ln -nsf '#{source}' '#{destination}'" if collision_accepted?
|
system "ln -nsf '#{source}' '#{destination}'" if collision_accepted?
|
||||||
when :conflict
|
when :conflict
|
||||||
say_status :conflict, "#{destination} exists", :red unless options[:quiet]
|
say_status :conflict, "#{destination} exists", :red \
|
||||||
|
unless options[:quiet]
|
||||||
|
|
||||||
if collision_accepted?
|
if collision_accepted?
|
||||||
system "rm -rf '#{destination}'" unless options[:pretend]
|
system "rm -rf '#{destination}'" unless options[:pretend]
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# -*- encoding : utf-8 -*-
|
# -*- encoding : utf-8 -*-
|
||||||
class Homesick
|
class Homesick
|
||||||
|
# A representation of Homesick's version number in constants, including a
|
||||||
|
# String of the entire version number
|
||||||
module Version
|
module Version
|
||||||
MAJOR = 1
|
MAJOR = 1
|
||||||
MINOR = 0
|
MINOR = 0
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ describe 'homesick' do
|
|||||||
|
|
||||||
expect($stdout).to receive(:print)
|
expect($stdout).to receive(:print)
|
||||||
expect($stdin).to receive(:gets).and_return('y')
|
expect($stdin).to receive(:gets).and_return('y')
|
||||||
expect_any_instance_of(Thor::Shell::Basic).to receive(:say_status).with('eval', kind_of(Pathname))
|
expect_any_instance_of(Thor::Shell::Basic).to \
|
||||||
|
receive(:say_status).with('eval', kind_of(Pathname))
|
||||||
homesick.clone local_repo
|
homesick.clone local_repo
|
||||||
|
|
||||||
castles.join('some_repo').join('testing').should exist
|
castles.join('some_repo').join('testing').should exist
|
||||||
@@ -102,8 +103,8 @@ describe 'homesick' do
|
|||||||
homesick.clone 'gitolite:pickled-vim.git'
|
homesick.clone 'gitolite:pickled-vim.git'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should throw an exception when trying to clone a malformed uri like ' \
|
it 'should throw an exception when trying to clone a malformed uri ' \
|
||||||
'malformed' do
|
'like malformed' do
|
||||||
homesick.should_not_receive(:git_clone)
|
homesick.should_not_receive(:git_clone)
|
||||||
expect { homesick.clone 'malformed' }.to raise_error
|
expect { homesick.clone 'malformed' }.to raise_error
|
||||||
end
|
end
|
||||||
@@ -133,7 +134,8 @@ describe 'homesick' do
|
|||||||
end"
|
end"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect_any_instance_of(Thor::Shell::Basic).to receive(:say_status).with('eval', kind_of(Pathname))
|
expect_any_instance_of(Thor::Shell::Basic).to \
|
||||||
|
receive(:say_status).with('eval', kind_of(Pathname))
|
||||||
homesick.rc castle
|
homesick.rc castle
|
||||||
|
|
||||||
castle.join('testing').should exist
|
castle.join('testing').should exist
|
||||||
@@ -153,7 +155,8 @@ describe 'homesick' do
|
|||||||
end"
|
end"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect_any_instance_of(Thor::Shell::Basic).to receive(:say_status).with('eval skip', /not evaling.+/, :blue)
|
expect_any_instance_of(Thor::Shell::Basic).to \
|
||||||
|
receive(:say_status).with('eval skip', /not evaling.+/, :blue)
|
||||||
homesick.rc castle
|
homesick.rc castle
|
||||||
|
|
||||||
castle.join('testing').should_not exist
|
castle.join('testing').should_not exist
|
||||||
@@ -397,7 +400,9 @@ describe 'homesick' do
|
|||||||
given_castle('castle_repo')
|
given_castle('castle_repo')
|
||||||
some_rc_file = home.file '.some_rc_file'
|
some_rc_file = home.file '.some_rc_file'
|
||||||
homesick.track(some_rc_file.to_s, 'castle_repo')
|
homesick.track(some_rc_file.to_s, 'castle_repo')
|
||||||
Capture.stdout { homesick.commit 'castle_repo', 'Adding a file to the test' }
|
Capture.stdout do
|
||||||
|
homesick.commit 'castle_repo', 'Adding a file to the test'
|
||||||
|
end
|
||||||
text = Capture.stdout { homesick.diff('castle_repo') }
|
text = Capture.stdout { homesick.diff('castle_repo') }
|
||||||
text.should eq('')
|
text.should eq('')
|
||||||
end
|
end
|
||||||
@@ -406,9 +411,11 @@ describe 'homesick' do
|
|||||||
given_castle('castle_repo')
|
given_castle('castle_repo')
|
||||||
some_rc_file = home.file '.some_rc_file'
|
some_rc_file = home.file '.some_rc_file'
|
||||||
homesick.track(some_rc_file.to_s, 'castle_repo')
|
homesick.track(some_rc_file.to_s, 'castle_repo')
|
||||||
Capture.stdout { homesick.commit 'castle_repo', 'Adding a file to the test' }
|
Capture.stdout do
|
||||||
|
homesick.commit 'castle_repo', 'Adding a file to the test'
|
||||||
|
end
|
||||||
File.open(some_rc_file.to_s, 'w') do |file|
|
File.open(some_rc_file.to_s, 'w') do |file|
|
||||||
file.puts "Some test text"
|
file.puts 'Some test text'
|
||||||
end
|
end
|
||||||
text = Capture.stdout { homesick.diff('castle_repo') }
|
text = Capture.stdout { homesick.diff('castle_repo') }
|
||||||
text.should =~ /diff --git.+Some test text$/m
|
text.should =~ /diff --git.+Some test text$/m
|
||||||
@@ -426,17 +433,24 @@ describe 'homesick' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'pull' do
|
describe 'pull' do
|
||||||
it 'should perform a pull, submodule init and update when the given castle exists' do
|
it 'should perform a pull, submodule init and update when the given ' \
|
||||||
|
'castle exists' do
|
||||||
given_castle('castle_repo')
|
given_castle('castle_repo')
|
||||||
homesick.stub(:system).once.with('git pull --quiet')
|
homesick.stub(:system).once.with('git pull --quiet')
|
||||||
homesick.stub(:system).once.with('git submodule --quiet init')
|
homesick.stub(:system).once.with('git submodule --quiet init')
|
||||||
homesick.stub(:system).once.with('git submodule --quiet update --init --recursive >/dev/null 2>&1')
|
homesick.stub(:system).once.with('git submodule --quiet update ' \
|
||||||
|
'--init --recursive >/dev/null 2>&1')
|
||||||
homesick.pull 'castle_repo'
|
homesick.pull 'castle_repo'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should print an error message when trying to pull a non-existant castle' do
|
it 'should print an error message when trying to pull a non-existant ' \
|
||||||
homesick.should_receive("say_status").once.with(:error, /Could not pull castle_repo, expected \/tmp\/construct_container.* exist and contain dotfiles/, :red)
|
'castle' do
|
||||||
expect { homesick.pull "castle_repo" }.to raise_error(SystemExit)
|
homesick.should_receive('say_status').once
|
||||||
|
.with(:error,
|
||||||
|
Regexp.new('Could not pull castle_repo, expected ' \
|
||||||
|
'/tmp/construct_container.* exist and contain dotfiles'),
|
||||||
|
:red)
|
||||||
|
expect { homesick.pull 'castle_repo' }.to raise_error(SystemExit)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '--all' do
|
describe '--all' do
|
||||||
@@ -444,9 +458,14 @@ describe 'homesick' do
|
|||||||
given_castle('castle_repo')
|
given_castle('castle_repo')
|
||||||
given_castle('glencairn')
|
given_castle('glencairn')
|
||||||
homesick.stub(:system).exactly(2).times.with('git pull --quiet')
|
homesick.stub(:system).exactly(2).times.with('git pull --quiet')
|
||||||
homesick.stub(:system).exactly(2).times.with('git submodule --quiet init')
|
homesick.stub(:system).exactly(2).times
|
||||||
homesick.stub(:system).exactly(2).times.with('git submodule --quiet update --init --recursive >/dev/null 2>&1')
|
.with('git submodule --quiet init')
|
||||||
Capture.stdout { Capture.stderr { homesick.invoke 'pull', [], all: true } }
|
homesick.stub(:system).exactly(2).times
|
||||||
|
.with('git submodule --quiet update --init --recursive ' \
|
||||||
|
'>/dev/null 2>&1')
|
||||||
|
Capture.stdout do
|
||||||
|
Capture.stderr { homesick.invoke 'pull', [], all: true }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -459,9 +478,14 @@ describe 'homesick' do
|
|||||||
homesick.push 'castle_repo'
|
homesick.push 'castle_repo'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should print an error message when trying to push a non-existant castle' do
|
it 'should print an error message when trying to push a non-existant '\
|
||||||
homesick.should_receive("say_status").once.with(:error, /Could not push castle_repo, expected \/tmp\/construct_container.* exist and contain dotfiles/, :red)
|
'castle' do
|
||||||
expect { homesick.push "castle_repo" }.to raise_error(SystemExit)
|
homesick.should_receive('say_status').once
|
||||||
|
.with(:error,
|
||||||
|
Regexp.new('Could not push castle_repo, expected ' \
|
||||||
|
'/tmp/construct_container.* exist and contain dotfiles'),
|
||||||
|
:red)
|
||||||
|
expect { homesick.push 'castle_repo' }.to raise_error(SystemExit)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user