From 474d69da0b4bbe07389e5a8c05c1af4ed6cee762 Mon Sep 17 00:00:00 2001 From: mail6543210 Date: Tue, 19 Sep 2017 20:26:01 +0800 Subject: [PATCH 01/10] Revert "Use source content instead of source path (fixes: #148)" This reverts commit ed397bdaf8ccde86a4b39863f2b68254f8a5c9bc. --- lib/homesick/utils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick/utils.rb b/lib/homesick/utils.rb index 701ec2a..e18cd17 100644 --- a/lib/homesick/utils.rb +++ b/lib/homesick/utils.rb @@ -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) From d3d6974b7b5146fcf3b49d7dc1281088392070b8 Mon Sep 17 00:00:00 2001 From: mail6543210 Date: Tue, 19 Sep 2017 20:29:06 +0800 Subject: [PATCH 02/10] Rename `content` to `source` It is a instance of Pathname, not binary content --- lib/homesick/cli.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/homesick/cli.rb b/lib/homesick/cli.rb index 159d470..43d401f 100644 --- a/lib/homesick/cli.rb +++ b/lib/homesick/cli.rb @@ -27,13 +27,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, source) unless destination.symlink? say "- #{destination.readlink}", :red, true - say "+ #{content.expand_path}", :green, true + say "+ #{source.expand_path}", :green, true end end From 62c934774b0f5616543a40ee4d2a6924c1b1c17e Mon Sep 17 00:00:00 2001 From: mail6543210 Date: Tue, 19 Sep 2017 20:30:15 +0800 Subject: [PATCH 03/10] Real fix for #148 --- lib/homesick/cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/homesick/cli.rb b/lib/homesick/cli.rb index 43d401f..d339dff 100644 --- a/lib/homesick/cli.rb +++ b/lib/homesick/cli.rb @@ -31,7 +31,7 @@ module Homesick destination = Pathname.new(destination) source = Pathname.new(source) return 'Unable to create diff: destination or content is a directory' if destination.directory? || source.directory? - return super(destination, source) unless destination.symlink? + return super(destination, File.binread(source)) unless destination.symlink? say "- #{destination.readlink}", :red, true say "+ #{source.expand_path}", :green, true end From 8c2a1d0f8485d99d24296af2e1c630f9faade0de Mon Sep 17 00:00:00 2001 From: mail6543210 Date: Sat, 23 Sep 2017 00:41:33 +0800 Subject: [PATCH 04/10] Add testcase --- spec/homesick_cli_spec.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/spec/homesick_cli_spec.rb b/spec/homesick_cli_spec.rb index 31fcfb4..46a9762 100644 --- a/spec/homesick_cli_spec.rb +++ b/spec/homesick_cli_spec.rb @@ -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 From 257e974c3864591717205092eb2dcba9f1c8ddfe Mon Sep 17 00:00:00 2001 From: Diego Rabatone Oliveira Date: Mon, 18 Dec 2017 13:40:44 -0200 Subject: [PATCH 05/10] Require fileutils correctly Fix #165 --- lib/homesick/cli.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/homesick/cli.rb b/lib/homesick/cli.rb index d339dff..957b79d 100644 --- a/lib/homesick/cli.rb +++ b/lib/homesick/cli.rb @@ -1,4 +1,5 @@ # -*- encoding : utf-8 -*- +require 'fileutils' require 'thor' module Homesick From 9d9cf66de6811aeec0c7c1828e5f494dac71bc71 Mon Sep 17 00:00:00 2001 From: Jeremy Cook Date: Wed, 20 Dec 2017 16:01:20 -0500 Subject: [PATCH 06/10] Prepare for release of new version --- ChangeLog.markdown | 5 +++++ lib/homesick/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 7fe0594..19f055a 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -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. diff --git a/lib/homesick/version.rb b/lib/homesick/version.rb index d36f102..a540369 100644 --- a/lib/homesick/version.rb +++ b/lib/homesick/version.rb @@ -5,7 +5,7 @@ module Homesick module Version MAJOR = 1 MINOR = 1 - PATCH = 5 + PATCH = 6 STRING = [MAJOR, MINOR, PATCH].compact.join('.') end From 7080321081cc85a322969b3a49c400b5fe564ff8 Mon Sep 17 00:00:00 2001 From: Jeremy Cook Date: Wed, 20 Dec 2017 16:03:17 -0500 Subject: [PATCH 07/10] Regenerate gemspec for version 1.1.6 --- homesick.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homesick.gemspec b/homesick.gemspec index 10120cf..9c700ea 100644 --- a/homesick.gemspec +++ b/homesick.gemspec @@ -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] From 001bd32bb3b1ca2c96b731c40012ac0e894bd1a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denny=20Sch=C3=A4fer?= Date: Thu, 11 Jan 2018 00:20:23 +0100 Subject: [PATCH 08/10] Fix markdown typo --- ChangeLog.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 19f055a..e598d92 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,4 +1,4 @@ -#1.1.6 +# 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 From 72d11c4a4731a36ba863cede306859ebf5273bb0 Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Wed, 7 Mar 2018 17:37:40 +0100 Subject: [PATCH 09/10] Fix tests on Ruby 2.5 --- spec/homesick_cli_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/homesick_cli_spec.rb b/spec/homesick_cli_spec.rb index 46a9762..5a2639c 100644 --- a/spec/homesick_cli_spec.rb +++ b/spec/homesick_cli_spec.rb @@ -739,6 +739,8 @@ describe Homesick::CLI do end it 'returns an error message when the $EDITOR environment variable is not set' do + # Return empty ENV, the test does not call it anyway + allow(ENV).to receive(:[]).and_return(nil) # Set the default editor to make sure it fails. allow(ENV).to receive(:[]).with('EDITOR').and_return(nil) expect(homesick).to receive('say_status').once @@ -747,6 +749,8 @@ describe Homesick::CLI do end it 'returns an error message when the given castle does not exist' do + # Return empty ENV, the test does not call it anyway + allow(ENV).to receive(:[]).and_return(nil) # 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 From dcef34c17daf11084dc1379d3b8383f647b9b89f Mon Sep 17 00:00:00 2001 From: Balint Reczey Date: Thu, 8 Mar 2018 08:46:36 +0100 Subject: [PATCH 10/10] Run Travis tests on Ruby 2.5.0, too --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3f9e004..46eb168 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: ruby rvm: + - 2.5.0 - 2.4.0 - 2.3.3 - 2.2.6