Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7080321081 | ||
|
|
9d9cf66de6 | ||
|
|
9e9a940825 | ||
|
|
257e974c38 | ||
|
|
615e31428c | ||
|
|
8c2a1d0f84 | ||
|
|
62c934774b | ||
|
|
d3d6974b7b | ||
|
|
474d69da0b | ||
|
|
db6a513d1d | ||
|
|
ae343c4cab | ||
|
|
a2b365fb6f | ||
|
|
4cb2006f41 | ||
|
|
66347d307f | ||
|
|
8f92a1b4f0 |
@@ -1,3 +1,8 @@
|
||||
#1.1.6
|
||||
* Makesure the FileUtils is imported correctly to avoid a potential error
|
||||
* Fixes an issue where comparing a diff would not use the content of the new file
|
||||
* Small documentation fixes
|
||||
|
||||
# 1.1.5
|
||||
* Fixed problem with version number being incorrect.
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ Alternatively, if it's on github, there's a slightly shorter way:
|
||||
|
||||
With the castle cloned, you can now link its contents into your home dir:
|
||||
|
||||
homesick symlink pickled-vim
|
||||
homesick link pickled-vim
|
||||
|
||||
You can remove symlinks anytime when you don't need them anymore
|
||||
|
||||
@@ -84,7 +84,7 @@ If you ever want to see what version of homesick you have type:
|
||||
|
||||
## .homesick_subdir
|
||||
|
||||
`homesick symlink` basically makes symlink to only first depth in `castle/home`. If you want to link nested files/directories, please use .homesick_subdir.
|
||||
`homesick link` basically makes symlink to only first depth in `castle/home`. If you want to link nested files/directories, please use .homesick_subdir.
|
||||
|
||||
For example, when you have castle like this:
|
||||
|
||||
@@ -114,7 +114,7 @@ castle/.homesick_subdir
|
||||
|
||||
.config
|
||||
|
||||
and run `homesick symlink CASTLE`. The result is:
|
||||
and run `homesick link CASTLE`. The result is:
|
||||
|
||||
~
|
||||
|-- .config
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
# DO NOT EDIT THIS FILE DIRECTLY
|
||||
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
||||
# -*- encoding: utf-8 -*-
|
||||
# stub: homesick 1.1.5 ruby lib
|
||||
# stub: homesick 1.1.6 ruby lib
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "homesick".freeze
|
||||
s.version = "1.1.5"
|
||||
s.version = "1.1.6"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
||||
s.require_paths = ["lib".freeze]
|
||||
s.authors = ["Joshua Nichols".freeze, "Yusuke Murata".freeze]
|
||||
s.date = "2017-03-23"
|
||||
s.date = "2017-12-20"
|
||||
s.description = "\n Your home directory is your castle. Don't leave your dotfiles behind.\n \n\n Homesick is sorta like rip, but for dotfiles. It uses git to clone a repository containing dotfiles, and saves them in ~/.homesick. It then allows you to symlink all the dotfiles into place with a single command. \n\n ".freeze
|
||||
s.email = ["josh@technicalpickles.com".freeze, "info@muratayusuke.com".freeze]
|
||||
s.executables = ["homesick".freeze]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
require 'fileutils'
|
||||
require 'thor'
|
||||
|
||||
module Homesick
|
||||
@@ -27,13 +28,13 @@ module Homesick
|
||||
# Hack in support for diffing symlinks
|
||||
# Also adds support for checking if destination or content is a directory
|
||||
shell_metaclass = class << shell; self; end
|
||||
shell_metaclass.send(:define_method, :show_diff) do |destination, content|
|
||||
shell_metaclass.send(:define_method, :show_diff) do |destination, source|
|
||||
destination = Pathname.new(destination)
|
||||
content = Pathname.new(content)
|
||||
return 'Unable to create diff: destination or content is a directory' if destination.directory? || content.directory?
|
||||
return super(destination, content) unless destination.symlink?
|
||||
source = Pathname.new(source)
|
||||
return 'Unable to create diff: destination or content is a directory' if destination.directory? || source.directory?
|
||||
return super(destination, File.binread(source)) unless destination.symlink?
|
||||
say "- #{destination.readlink}", :red, true
|
||||
say "+ #{content.expand_path}", :green, true
|
||||
say "+ #{source.expand_path}", :green, true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ module Homesick
|
||||
def check_castle_existance(name, action)
|
||||
return if castle_dir(name).exist?
|
||||
say_status :error,
|
||||
"Could not #{action} #{name}, expected #{castle_dir(name)} exist and contain dotfiles",
|
||||
"Could not #{action} #{name}, expected #{castle_dir(name)} to exist and contain dotfiles",
|
||||
:red
|
||||
exit(1)
|
||||
end
|
||||
@@ -150,7 +150,7 @@ module Homesick
|
||||
|
||||
def collision_accepted?(destination, source)
|
||||
fail "Arguments must be instances of Pathname, #{destination.class.name} and #{source.class.name} given" unless destination.instance_of?(Pathname) && source.instance_of?(Pathname)
|
||||
options[:force] || shell.file_collision(destination) { File.binread(source) }
|
||||
options[:force] || shell.file_collision(destination) { source }
|
||||
end
|
||||
|
||||
def each_file(castle, basedir, subdirs)
|
||||
|
||||
@@ -5,7 +5,7 @@ module Homesick
|
||||
module Version
|
||||
MAJOR = 1
|
||||
MINOR = 1
|
||||
PATCH = 5
|
||||
PATCH = 6
|
||||
|
||||
STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
||||
end
|
||||
|
||||
@@ -331,6 +331,40 @@ describe Homesick::CLI do
|
||||
expect(home.join('.some_dotfile').readlink).to eq(dotfile)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when call and some files conflict' do
|
||||
it 'shows differences for conflicting text files' do
|
||||
contents = {:castle => 'castle has new content', :home => 'home already has content'}
|
||||
|
||||
dotfile = castle.file('text')
|
||||
File.open(dotfile.to_s, 'w') do |f|
|
||||
f.write contents[:castle]
|
||||
end
|
||||
File.open(home.join('text').to_s, 'w') do |f|
|
||||
f.write contents[:home]
|
||||
end
|
||||
message = Capture.stdout { homesick.shell.show_diff(home.join('text'), dotfile) }
|
||||
expect(message.b).to match(/- ?#{contents[:home]}\n.*\+ ?#{contents[:castle]}$/m)
|
||||
end
|
||||
it 'shows message or differences for conflicting binary files' do
|
||||
# content which contains NULL character, without any parentheses, braces, ...
|
||||
contents = {:castle => (0..255).step(30).map{|e| e.chr}.join(), :home => (0..255).step(30).reverse_each.map{|e| e.chr}.join()}
|
||||
|
||||
dotfile = castle.file('binary')
|
||||
File.open(dotfile.to_s, 'w') do |f|
|
||||
f.write contents[:castle]
|
||||
end
|
||||
File.open(home.join('binary').to_s, 'w') do |f|
|
||||
f.write contents[:home]
|
||||
end
|
||||
message = Capture.stdout { homesick.shell.show_diff(home.join('binary'), dotfile) }
|
||||
if homesick.shell.is_a?(Thor::Shell::Color)
|
||||
expect(message.b).to match(/- ?#{contents[:home]}\n.*\+ ?#{contents[:castle]}$/m)
|
||||
elsif homesick.shell.is_a?(Thor::Shell::Basic)
|
||||
expect(message.b).to match(/^Binary files .+ differ$/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'unlink' do
|
||||
@@ -499,7 +533,7 @@ describe Homesick::CLI do
|
||||
it 'prints an error message when trying to pull a non-existant castle' do
|
||||
expect(homesick).to receive('say_status').once
|
||||
.with(:error,
|
||||
/Could not pull castle_repo, expected .* exist and contain dotfiles/,
|
||||
/Could not pull castle_repo, expected .* to exist and contain dotfiles/,
|
||||
:red)
|
||||
expect { homesick.pull 'castle_repo' }.to raise_error(SystemExit)
|
||||
end
|
||||
@@ -529,7 +563,7 @@ describe Homesick::CLI do
|
||||
|
||||
it 'prints an error message when trying to push a non-existant castle' do
|
||||
expect(homesick).to receive('say_status').once
|
||||
.with(:error, /Could not push castle_repo, expected .* exist and contain dotfiles/, :red)
|
||||
.with(:error, /Could not push castle_repo, expected .* to exist and contain dotfiles/, :red)
|
||||
expect { homesick.push 'castle_repo' }.to raise_error(SystemExit)
|
||||
end
|
||||
end
|
||||
@@ -687,7 +721,7 @@ describe Homesick::CLI do
|
||||
|
||||
it 'returns an error message when the given castle does not exist' do
|
||||
expect(homesick).to receive('say_status').once
|
||||
.with(:error, /Could not cd castle_repo, expected .* exist and contain dotfiles/, :red)
|
||||
.with(:error, /Could not cd castle_repo, expected .* to exist and contain dotfiles/, :red)
|
||||
expect { homesick.cd 'castle_repo' }.to raise_error(SystemExit)
|
||||
end
|
||||
end
|
||||
@@ -716,7 +750,7 @@ describe Homesick::CLI do
|
||||
# Set a default just in case none is set
|
||||
allow(ENV).to receive(:[]).with('EDITOR').and_return('vim')
|
||||
allow(homesick).to receive('say_status').once
|
||||
.with(:error, /Could not open castle_repo, expected .* exist and contain dotfiles/, :red)
|
||||
.with(:error, /Could not open castle_repo, expected .* to exist and contain dotfiles/, :red)
|
||||
expect { homesick.open 'castle_repo' }.to raise_error(SystemExit)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user