Compare commits
69 Commits
v1.1.3
...
ee4388b0f4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee4388b0f4 | ||
|
|
a44a514007 | ||
|
|
9431cb78af | ||
|
|
46c52769a6 | ||
|
|
fdb57cd846 | ||
|
|
ff387280d5 | ||
|
|
f09c62d922 | ||
|
|
dd7d52a25d | ||
|
|
f1630ece79 | ||
|
|
11ee8cdc0d | ||
|
|
ceb08cbe22 | ||
|
|
057e1cfc59 | ||
|
|
89f3000d8b | ||
|
|
36e3cb6bbf | ||
|
|
9ebae75e7d | ||
|
|
35e1909790 | ||
|
|
3b633ed326 | ||
|
|
fdf2da84dd | ||
|
|
e561566b46 | ||
|
|
dcef34c17d | ||
|
|
72d11c4a47 | ||
|
|
c2457bae9f | ||
|
|
001bd32bb3 | ||
|
|
7080321081 | ||
|
|
9d9cf66de6 | ||
|
|
9e9a940825 | ||
|
|
257e974c38 | ||
|
|
615e31428c | ||
|
|
8c2a1d0f84 | ||
|
|
62c934774b | ||
|
|
d3d6974b7b | ||
|
|
474d69da0b | ||
|
|
db6a513d1d | ||
|
|
ae343c4cab | ||
|
|
a2b365fb6f | ||
|
|
4cb2006f41 | ||
|
|
66347d307f | ||
|
|
8f92a1b4f0 | ||
|
|
7a2df591c0 | ||
|
|
4923265dea | ||
|
|
79421580e9 | ||
|
|
cabde9e5f1 | ||
|
|
0d60ae9d1a | ||
|
|
d5317b8e17 | ||
|
|
3b8a5b4be4 | ||
|
|
6590a1eeff | ||
|
|
693ae5f05e | ||
|
|
da3002f199 | ||
|
|
feaaab2fa4 | ||
|
|
59f75711a4 | ||
|
|
f24030b51f | ||
|
|
71bb120a12 | ||
|
|
85f46e01b1 | ||
|
|
c5b24b9b38 | ||
|
|
68460af45e | ||
|
|
5614b6b8b3 | ||
|
|
570b063632 | ||
|
|
1d398587d0 | ||
|
|
085853faaa | ||
|
|
21b4e344a9 | ||
|
|
a6194dfe8b | ||
|
|
5692194fa2 | ||
|
|
11745098c2 | ||
|
|
b1bb0c996c | ||
|
|
a62039da50 | ||
|
|
4bfd1c60c2 | ||
|
|
f0e11abb5b | ||
|
|
ed397bdaf8 | ||
|
|
2f5e20d963 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -13,7 +13,7 @@ pkg
|
||||
|
||||
.bundle
|
||||
|
||||
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
||||
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
||||
#
|
||||
# * Create a file at ~/.gitignore
|
||||
# * Include files you want ignored
|
||||
@@ -48,3 +48,6 @@ Gemfile.lock
|
||||
vendor/
|
||||
|
||||
homesick*.gem
|
||||
|
||||
# rbenv configuration
|
||||
.ruby-version
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
language: ruby
|
||||
rvm:
|
||||
- 2.1.0
|
||||
- 2.0.0
|
||||
- 1.9.3
|
||||
- 2.5.0
|
||||
- 2.4.0
|
||||
- 2.3.3
|
||||
- 2.2.6
|
||||
sudo: false
|
||||
|
||||
@@ -1,19 +1,34 @@
|
||||
#1.1.3
|
||||
* Allow a destinaton to be passed when cloning a castle
|
||||
# 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.
|
||||
|
||||
# 1.1.4
|
||||
* Make sure symlink conflicts are explicitly communicated to a user and symlinks are not silently overwritten
|
||||
* Use real paths of symlinks when linking a castle into home
|
||||
* Fix a problem when in a diff when asking a user to resolve a conflict
|
||||
* Some code refactoring and fixes
|
||||
|
||||
# 1.1.3
|
||||
* Allow a destination to be passed when cloning a castle
|
||||
* Make sure `homesick edit` opens default editor in the root of the given castle
|
||||
* Fixed bug when diffing edited files
|
||||
* Fixed crashing bug when attempting to diff directories
|
||||
* Ensure that messages are escaped correctly on `git commit all`
|
||||
#1.1.2
|
||||
|
||||
# 1.1.2
|
||||
* Added '--force' option to the rc command to bypass confirmation checks when running a .homesickrc file
|
||||
* Added a check to make sure that a minimum of Git 1.8.0 is installed. This stops Homesick failing silently if Git is not installed.
|
||||
* Code refactoring and fixes.
|
||||
|
||||
#1.1.0
|
||||
# 1.1.0
|
||||
* Added exec and exec_all commands to run commands inside one or all clones castles.
|
||||
* Code refactoring.
|
||||
|
||||
#1.0.0
|
||||
# 1.0.0
|
||||
* Removed support for Ruby 1.8.7
|
||||
* Added a version command
|
||||
|
||||
@@ -40,19 +55,19 @@
|
||||
|
||||
# 0.9.1
|
||||
* Fixed small bugs: #35, #40
|
||||
|
||||
|
||||
# 0.9.0
|
||||
* Introduce .homesick_subdir #39
|
||||
|
||||
|
||||
# 0.8.1
|
||||
*Fixed `homesick list` bug on ruby 2.0 #37
|
||||
|
||||
* Fixed `homesick list` bug on ruby 2.0 #37
|
||||
|
||||
# 0.8.0
|
||||
* Introduce commit & push command
|
||||
* commit changes in castle and push to remote
|
||||
* commit changes in castle and push to remote
|
||||
* Enable recursive submodule update
|
||||
* Git add when track
|
||||
|
||||
|
||||
# 0.7.0
|
||||
* Fixed double-cloning #14
|
||||
* New option for pull command: --all
|
||||
|
||||
38
Gemfile
38
Gemfile
@@ -1,28 +1,36 @@
|
||||
require 'rbconfig'
|
||||
source 'https://rubygems.org'
|
||||
|
||||
this_ruby = Gem::Version.new(RUBY_VERSION)
|
||||
ruby_230 = Gem::Version.new('2.3.0')
|
||||
|
||||
# Add dependencies required to use your gem here.
|
||||
gem "thor", ">= 0.14.0"
|
||||
gem 'thor', '>= 0.14.0'
|
||||
|
||||
# Add dependencies to develop your gem here.
|
||||
# Include everything needed to run rake, tests, features, etc.
|
||||
group :development do
|
||||
gem "rake", ">= 0.8.7"
|
||||
gem "rspec", "~> 3.1.0"
|
||||
gem "guard"
|
||||
gem "guard-rspec"
|
||||
gem "rb-readline", "~> 0.5.0"
|
||||
gem "jeweler", ">= 1.6.2"
|
||||
gem 'capture-output', '~> 1.0.0'
|
||||
gem 'coveralls', require: false
|
||||
gem "test_construct"
|
||||
gem "capture-output", "~> 1.0.0"
|
||||
if RbConfig::CONFIG['host_os'] =~ /linux|freebsd|openbsd|sunos|solaris/
|
||||
gem 'guard'
|
||||
gem 'guard-rspec'
|
||||
gem 'jeweler', '>= 1.6.2', '< 2.2' if this_ruby < ruby_230
|
||||
gem 'jeweler', '>= 1.6.2' if this_ruby >= ruby_230
|
||||
gem 'rake', '>= 0.8.7'
|
||||
gem 'rb-readline', '~> 0.5.0'
|
||||
gem 'rspec', '~> 3.5.0'
|
||||
gem 'rubocop'
|
||||
gem 'test_construct'
|
||||
|
||||
install_if -> { RUBY_PLATFORM =~ /linux|freebsd|openbsd|sunos|solaris/ } do
|
||||
gem 'libnotify'
|
||||
end
|
||||
if RbConfig::CONFIG['host_os'] =~ /darwin|mac os/
|
||||
gem 'terminal-notifier-guard', '~> 1.6.1'
|
||||
|
||||
install_if -> { RUBY_PLATFORM =~ /darwin/ } do
|
||||
gem 'terminal-notifier-guard', '~> 1.7.0'
|
||||
end
|
||||
if RUBY_VERSION >= '1.9.2'
|
||||
gem "rubocop"
|
||||
|
||||
install_if -> { this_ruby < ruby_230 } do
|
||||
gem 'listen', '< 3'
|
||||
gem 'rack', '~> 2.0.6'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
@@ -164,12 +164,12 @@ and castle
|
||||
|
||||
Homesick is tested on the following Ruby versions:
|
||||
|
||||
* 1.9.3
|
||||
* 2.0.0
|
||||
* 2.1.0
|
||||
* 2.2.6
|
||||
* 2.3.3
|
||||
* 2.4.0
|
||||
|
||||
## Note on Patches/Pull Requests
|
||||
|
||||
|
||||
* Fork the project.
|
||||
* Make your feature addition or bug fix.
|
||||
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
||||
|
||||
106
homesick.gemspec
106
homesick.gemspec
@@ -2,19 +2,19 @@
|
||||
# DO NOT EDIT THIS FILE DIRECTLY
|
||||
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
||||
# -*- encoding: utf-8 -*-
|
||||
# stub: homesick 1.1.3 ruby lib
|
||||
# stub: homesick 1.1.6 ruby lib
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "homesick"
|
||||
s.version = "1.1.3"
|
||||
s.name = "homesick".freeze
|
||||
s.version = "1.1.6"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
s.require_paths = ["lib"]
|
||||
s.authors = ["Joshua Nichols", "Yusuke Murata"]
|
||||
s.date = "2015-10-31"
|
||||
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 "
|
||||
s.email = ["josh@technicalpickles.com", "info@muratayusuke.com"]
|
||||
s.executables = ["homesick"]
|
||||
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-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]
|
||||
s.extra_rdoc_files = [
|
||||
"ChangeLog.markdown",
|
||||
"LICENSE",
|
||||
@@ -43,51 +43,63 @@ Gem::Specification.new do |s|
|
||||
"spec/spec.opts",
|
||||
"spec/spec_helper.rb"
|
||||
]
|
||||
s.homepage = "http://github.com/technicalpickles/homesick"
|
||||
s.licenses = ["MIT"]
|
||||
s.rubygems_version = "2.2.2"
|
||||
s.summary = "Your home directory is your castle. Don't leave your dotfiles behind."
|
||||
s.homepage = "http://github.com/technicalpickles/homesick".freeze
|
||||
s.licenses = ["MIT".freeze]
|
||||
s.rubygems_version = "2.6.11".freeze
|
||||
s.summary = "Your home directory is your castle. Don't leave your dotfiles behind.".freeze
|
||||
|
||||
if s.respond_to? :specification_version then
|
||||
s.specification_version = 4
|
||||
|
||||
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
||||
s.add_runtime_dependency(%q<thor>, [">= 0.14.0"])
|
||||
s.add_development_dependency(%q<rake>, [">= 0.8.7"])
|
||||
s.add_development_dependency(%q<rspec>, ["~> 3.1.0"])
|
||||
s.add_development_dependency(%q<guard>, [">= 0"])
|
||||
s.add_development_dependency(%q<guard-rspec>, [">= 0"])
|
||||
s.add_development_dependency(%q<rb-readline>, ["~> 0.5.0"])
|
||||
s.add_development_dependency(%q<jeweler>, [">= 1.6.2"])
|
||||
s.add_development_dependency(%q<coveralls>, [">= 0"])
|
||||
s.add_development_dependency(%q<test_construct>, [">= 0"])
|
||||
s.add_development_dependency(%q<capture-output>, ["~> 1.0.0"])
|
||||
s.add_development_dependency(%q<rubocop>, [">= 0"])
|
||||
s.add_runtime_dependency(%q<thor>.freeze, [">= 0.14.0"])
|
||||
s.add_development_dependency(%q<capture-output>.freeze, ["~> 1.0.0"])
|
||||
s.add_development_dependency(%q<coveralls>.freeze, [">= 0"])
|
||||
s.add_development_dependency(%q<guard>.freeze, [">= 0"])
|
||||
s.add_development_dependency(%q<guard-rspec>.freeze, [">= 0"])
|
||||
s.add_development_dependency(%q<jeweler>.freeze, [">= 1.6.2"])
|
||||
s.add_development_dependency(%q<rake>.freeze, [">= 0.8.7"])
|
||||
s.add_development_dependency(%q<rb-readline>.freeze, ["~> 0.5.0"])
|
||||
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
||||
s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
|
||||
s.add_development_dependency(%q<test_construct>.freeze, [">= 0"])
|
||||
s.add_development_dependency(%q<libnotify>.freeze, [">= 0"])
|
||||
s.add_development_dependency(%q<terminal-notifier-guard>.freeze, ["~> 1.7.0"])
|
||||
s.add_development_dependency(%q<listen>.freeze, ["< 3"])
|
||||
s.add_development_dependency(%q<rack>.freeze, ["< 2"])
|
||||
else
|
||||
s.add_dependency(%q<thor>, [">= 0.14.0"])
|
||||
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
||||
s.add_dependency(%q<rspec>, ["~> 3.1.0"])
|
||||
s.add_dependency(%q<guard>, [">= 0"])
|
||||
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
||||
s.add_dependency(%q<rb-readline>, ["~> 0.5.0"])
|
||||
s.add_dependency(%q<jeweler>, [">= 1.6.2"])
|
||||
s.add_dependency(%q<coveralls>, [">= 0"])
|
||||
s.add_dependency(%q<test_construct>, [">= 0"])
|
||||
s.add_dependency(%q<capture-output>, ["~> 1.0.0"])
|
||||
s.add_dependency(%q<rubocop>, [">= 0"])
|
||||
s.add_dependency(%q<thor>.freeze, [">= 0.14.0"])
|
||||
s.add_dependency(%q<capture-output>.freeze, ["~> 1.0.0"])
|
||||
s.add_dependency(%q<coveralls>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<guard>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<guard-rspec>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<jeweler>.freeze, [">= 1.6.2"])
|
||||
s.add_dependency(%q<rake>.freeze, [">= 0.8.7"])
|
||||
s.add_dependency(%q<rb-readline>.freeze, ["~> 0.5.0"])
|
||||
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
||||
s.add_dependency(%q<rubocop>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<test_construct>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<libnotify>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<terminal-notifier-guard>.freeze, ["~> 1.7.0"])
|
||||
s.add_dependency(%q<listen>.freeze, ["< 3"])
|
||||
s.add_dependency(%q<rack>.freeze, ["< 2"])
|
||||
end
|
||||
else
|
||||
s.add_dependency(%q<thor>, [">= 0.14.0"])
|
||||
s.add_dependency(%q<rake>, [">= 0.8.7"])
|
||||
s.add_dependency(%q<rspec>, ["~> 3.1.0"])
|
||||
s.add_dependency(%q<guard>, [">= 0"])
|
||||
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
||||
s.add_dependency(%q<rb-readline>, ["~> 0.5.0"])
|
||||
s.add_dependency(%q<jeweler>, [">= 1.6.2"])
|
||||
s.add_dependency(%q<coveralls>, [">= 0"])
|
||||
s.add_dependency(%q<test_construct>, [">= 0"])
|
||||
s.add_dependency(%q<capture-output>, ["~> 1.0.0"])
|
||||
s.add_dependency(%q<rubocop>, [">= 0"])
|
||||
s.add_dependency(%q<thor>.freeze, [">= 0.14.0"])
|
||||
s.add_dependency(%q<capture-output>.freeze, ["~> 1.0.0"])
|
||||
s.add_dependency(%q<coveralls>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<guard>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<guard-rspec>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<jeweler>.freeze, [">= 1.6.2"])
|
||||
s.add_dependency(%q<rake>.freeze, [">= 0.8.7"])
|
||||
s.add_dependency(%q<rb-readline>.freeze, ["~> 0.5.0"])
|
||||
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
||||
s.add_dependency(%q<rubocop>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<test_construct>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<libnotify>.freeze, [">= 0"])
|
||||
s.add_dependency(%q<terminal-notifier-guard>.freeze, ["~> 1.7.0"])
|
||||
s.add_dependency(%q<listen>.freeze, ["< 3"])
|
||||
s.add_dependency(%q<rack>.freeze, ["< 2"])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,14 +1,29 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
require 'homesick/actions/file_actions'
|
||||
require 'homesick/actions/git_actions'
|
||||
require 'homesick/version'
|
||||
require 'homesick/utils'
|
||||
require 'homesick/cli'
|
||||
require 'fileutils'
|
||||
|
||||
# Homesick's top-level module
|
||||
module Homesick
|
||||
GITHUB_NAME_REPO_PATTERN = %r{\A([A-Za-z0-9_-]+/[A-Za-z0-9_-]+)\Z}
|
||||
SUBDIR_FILENAME = '.homesick_subdir'
|
||||
GITHUB_NAME_REPO_PATTERN = %r{\A([A-Za-z0-9_-]+/[A-Za-z0-9_-]+)\Z}.freeze
|
||||
SUBDIR_FILENAME = '.homesick_subdir'.freeze
|
||||
|
||||
DEFAULT_CASTLE_NAME = 'dotfiles'
|
||||
DEFAULT_CASTLE_NAME = 'dotfiles'.freeze
|
||||
QUIETABLE = [:say_status].freeze
|
||||
|
||||
PRETENDABLE = [:system].freeze
|
||||
|
||||
QUIETABLE.each do |method_name|
|
||||
define_method(method_name) do |*args|
|
||||
super(*args) unless options[:quiet]
|
||||
end
|
||||
end
|
||||
|
||||
PRETENDABLE.each do |method_name|
|
||||
define_method(method_name) do |*args|
|
||||
super(*args) unless options[:pretend]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
module Homesick
|
||||
module Actions
|
||||
# File-related helper methods for Homesick
|
||||
module FileActions
|
||||
protected
|
||||
|
||||
def mv(source, destination)
|
||||
source = Pathname.new(source)
|
||||
destination = Pathname.new(destination + source.basename)
|
||||
case
|
||||
when destination.exist? && (options[:force] || shell.file_collision(destination) { source })
|
||||
say_status :conflict, "#{destination} exists", :red
|
||||
FileUtils.mv source, destination unless options[:pretend]
|
||||
else
|
||||
FileUtils.mv source, destination unless options[:pretend]
|
||||
end
|
||||
say_status :conflict, "#{destination} exists", :red if destination.exist? && (options[:force] || shell.file_collision(destination) { source })
|
||||
FileUtils.mv source, destination unless options[:pretend]
|
||||
end
|
||||
|
||||
def rm_rf(dir)
|
||||
@@ -24,7 +20,7 @@ module Homesick
|
||||
target = Pathname.new(target)
|
||||
|
||||
if target.symlink?
|
||||
say_status :unlink, "#{target.expand_path}", :green
|
||||
say_status :unlink, target.expand_path.to_s, :green
|
||||
FileUtils.rm_rf target
|
||||
else
|
||||
say_status :conflict, "#{target} is not a symlink", :red
|
||||
@@ -42,47 +38,40 @@ module Homesick
|
||||
end
|
||||
|
||||
def ln_s(source, destination)
|
||||
source = Pathname.new(source)
|
||||
source = Pathname.new(source).realpath
|
||||
destination = Pathname.new(destination)
|
||||
FileUtils.mkdir_p destination.dirname
|
||||
|
||||
action = if destination.symlink? && destination.readlink == source
|
||||
:identical
|
||||
elsif destination.symlink?
|
||||
:symlink_conflict
|
||||
elsif destination.exist?
|
||||
:conflict
|
||||
else
|
||||
:success
|
||||
end
|
||||
action = :success
|
||||
action = :identical if destination.symlink? && destination.readlink == source
|
||||
action = :symlink_conflict if destination.symlink?
|
||||
action = :conflict if destination.exist?
|
||||
|
||||
handle_symlink_action action, source, destination
|
||||
end
|
||||
|
||||
def handle_symlink_action(action, source, destination)
|
||||
case action
|
||||
when :identical
|
||||
if action == :identical
|
||||
say_status :identical, destination.expand_path, :blue
|
||||
when :symlink_conflict
|
||||
say_status :conflict,
|
||||
"#{destination} exists and points to #{destination.readlink}",
|
||||
:red
|
||||
|
||||
FileUtils.rm destination
|
||||
FileUtils.ln_s source, destination, force: true unless options[:pretend]
|
||||
when :conflict
|
||||
say_status :conflict, "#{destination} exists", :red
|
||||
|
||||
return
|
||||
end
|
||||
message = generate_symlink_message action, source, destination
|
||||
if %i[symlink_conflict conflict].include?(action)
|
||||
say_status :conflict, message, :red
|
||||
if collision_accepted?(destination, source)
|
||||
FileUtils.rm_r destination, force: true unless options[:pretend]
|
||||
FileUtils.ln_s source, destination, force: true unless options[:pretend]
|
||||
end
|
||||
else
|
||||
say_status :symlink,
|
||||
"#{source.expand_path} to #{destination.expand_path}",
|
||||
:green
|
||||
FileUtils.ln_s source, destination unless options[:pretend]
|
||||
say_status :symlink, message, :green
|
||||
end
|
||||
FileUtils.ln_s source, destination, force: true unless options[:pretend]
|
||||
end
|
||||
|
||||
def generate_symlink_message(action, source, destination)
|
||||
message = "#{source.expand_path} to #{destination.expand_path}"
|
||||
message = "#{destination} exists and points to #{destination.readlink}" if action == :symlink_conflict
|
||||
message = "#{destination} exists" if action == :conflict
|
||||
message
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
module Homesick
|
||||
module Actions
|
||||
# Git-related helper methods for Homesick
|
||||
@@ -8,18 +7,20 @@ module Homesick
|
||||
major: 1,
|
||||
minor: 8,
|
||||
patch: 0
|
||||
}
|
||||
}.freeze
|
||||
STRING = MIN_VERSION.values.join('.')
|
||||
|
||||
def git_version_correct?
|
||||
info = `git --version`.scan(/(\d+)\.(\d+)\.(\d+)/).flatten.map(&:to_i)
|
||||
return false unless info.count == 3
|
||||
current_version = Hash[[:major, :minor, :patch].zip(info)]
|
||||
return true if current_version.eql?(MIN_VERSION)
|
||||
return true if current_version[:major] > MIN_VERSION[:major]
|
||||
return true if current_version[:major] == MIN_VERSION[:major] && current_version[:minor] > MIN_VERSION[:minor]
|
||||
return true if current_version[:major] == MIN_VERSION[:major] && current_version[:minor] == MIN_VERSION[:minor] && current_version[:patch] >= MIN_VERSION[:patch]
|
||||
false
|
||||
|
||||
current_version = Hash[%i[major minor patch].zip(info)]
|
||||
major_equals = current_version.eql?(MIN_VERSION)
|
||||
major_greater = current_version[:major] > MIN_VERSION[:major]
|
||||
minor_greater = current_version[:major] == MIN_VERSION[:major] && current_version[:minor] > MIN_VERSION[:minor]
|
||||
patch_greater = current_version[:major] == MIN_VERSION[:major] && current_version[:minor] == MIN_VERSION[:minor] && current_version[:patch] >= MIN_VERSION[:patch]
|
||||
|
||||
major_equals || major_greater || minor_greater || patch_greater
|
||||
end
|
||||
|
||||
# TODO: move this to be more like thor's template, empty_directory, etc
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
require 'fileutils'
|
||||
require 'thor'
|
||||
|
||||
module Homesick
|
||||
@@ -24,27 +24,17 @@ module Homesick
|
||||
say_status :error, "Git version >= #{Homesick::Actions::GitActions::STRING} must be installed to use Homesick", :red
|
||||
exit(1)
|
||||
end
|
||||
# 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|
|
||||
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?
|
||||
say "- #{destination.readlink}", :red, true
|
||||
say "+ #{content.expand_path}", :green, true
|
||||
end
|
||||
configure_symlinks_diff
|
||||
end
|
||||
|
||||
desc 'clone URI CASTLE_NAME', 'Clone +uri+ as a castle with name CASTLE_NAME for homesick'
|
||||
def clone(uri, destination=nil)
|
||||
def clone(uri, destination = nil)
|
||||
destination = Pathname.new(destination) unless destination.nil?
|
||||
|
||||
inside repos_dir do
|
||||
if File.exist?(uri)
|
||||
uri = Pathname.new(uri).expand_path
|
||||
fail "Castle already cloned to #{uri}" if uri.to_s.start_with?(repos_dir.to_s)
|
||||
raise "Castle already cloned to #{uri}" if uri.to_s.start_with?(repos_dir.to_s)
|
||||
|
||||
destination = uri.basename if destination.nil?
|
||||
|
||||
@@ -57,7 +47,7 @@ module Homesick
|
||||
destination = Pathname.new(Regexp.last_match[1].gsub(/\.git$/, '')).basename if destination.nil?
|
||||
git_clone uri, destination: destination
|
||||
else
|
||||
fail "Unknown URI format: #{uri}"
|
||||
raise "Unknown URI format: #{uri}"
|
||||
end
|
||||
|
||||
setup_castle(destination)
|
||||
@@ -66,6 +56,7 @@ module Homesick
|
||||
|
||||
desc 'rc CASTLE', 'Run the .homesickrc for the specified castle'
|
||||
method_option :force,
|
||||
type: :boolean,
|
||||
default: false,
|
||||
desc: 'Evaluate .homesickrc without prompting.'
|
||||
def rc(name = DEFAULT_CASTLE_NAME)
|
||||
@@ -73,8 +64,10 @@ module Homesick
|
||||
destination = Pathname.new(name)
|
||||
homesickrc = destination.join('.homesickrc').expand_path
|
||||
return unless homesickrc.exist?
|
||||
|
||||
proceed = options[:force] || shell.yes?("#{name} has a .homesickrc. Proceed with evaling it? (This could be destructive)")
|
||||
return say_status 'eval skip', "not evaling #{homesickrc}, #{destination} may need manual configuration", :blue unless proceed
|
||||
|
||||
say_status 'eval', homesickrc
|
||||
inside destination do
|
||||
eval homesickrc.read, binding, homesickrc.expand_path.to_s
|
||||
@@ -128,16 +121,18 @@ module Homesick
|
||||
|
||||
desc 'link CASTLE', 'Symlinks all dotfiles from the specified castle'
|
||||
method_option :force,
|
||||
type: :boolean,
|
||||
default: false,
|
||||
desc: 'Overwrite existing conflicting symlinks without prompting.'
|
||||
def link(name = DEFAULT_CASTLE_NAME)
|
||||
check_castle_existance(name, 'symlink')
|
||||
|
||||
inside castle_dir(name) do
|
||||
castle_path = castle_dir(name)
|
||||
inside castle_path do
|
||||
subdirs = subdirs(name)
|
||||
|
||||
# link files
|
||||
symlink_each(name, castle_dir(name), subdirs)
|
||||
symlink_each(name, castle_path, subdirs)
|
||||
|
||||
# link files in subdirs
|
||||
subdirs.each do |subdir|
|
||||
|
||||
@@ -1,25 +1,8 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
require 'pathname'
|
||||
|
||||
module Homesick
|
||||
# Various utility methods that are used by Homesick
|
||||
module Utils
|
||||
QUIETABLE = ['say_status']
|
||||
|
||||
PRETENDABLE = ['system']
|
||||
|
||||
QUIETABLE.each do |method_name|
|
||||
define_method(method_name) do |*args|
|
||||
super(*args) unless options[:quiet]
|
||||
end
|
||||
end
|
||||
|
||||
PRETENDABLE.each do |method_name|
|
||||
define_method(method_name) do |*args|
|
||||
super(*args) unless options[:pretend]
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def home_dir
|
||||
@@ -36,8 +19,9 @@ 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
|
||||
@@ -149,47 +133,11 @@ module Homesick
|
||||
end
|
||||
|
||||
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)
|
||||
raise "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) { source }
|
||||
end
|
||||
|
||||
def each_file(castle, basedir, subdirs)
|
||||
absolute_basedir = Pathname.new(basedir).expand_path
|
||||
inside basedir do
|
||||
files = Pathname.glob('{.*,*}').reject do |a|
|
||||
['.', '..'].include?(a.to_s)
|
||||
end
|
||||
files.each do |path|
|
||||
absolute_path = path.expand_path
|
||||
castle_home = castle_dir(castle)
|
||||
|
||||
# make ignore dirs
|
||||
ignore_dirs = []
|
||||
subdirs.each do |subdir|
|
||||
# ignore all parent of each line in subdir file
|
||||
Pathname.new(subdir).ascend do |p|
|
||||
ignore_dirs.push(p)
|
||||
end
|
||||
end
|
||||
|
||||
# ignore dirs written in subdir file
|
||||
matched = false
|
||||
ignore_dirs.uniq.each do |ignore_dir|
|
||||
if absolute_path == castle_home.join(ignore_dir)
|
||||
matched = true
|
||||
break
|
||||
end
|
||||
end
|
||||
next if matched
|
||||
|
||||
relative_dir = absolute_basedir.relative_path_from(castle_home)
|
||||
home_path = home_dir.join(relative_dir).join(path)
|
||||
|
||||
yield(absolute_path, home_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def unsymlink_each(castle, basedir, subdirs)
|
||||
each_file(castle, basedir, subdirs) do |_absolute_path, home_path|
|
||||
rm_link home_path
|
||||
@@ -212,5 +160,56 @@ module Homesick
|
||||
|
||||
rc(path)
|
||||
end
|
||||
|
||||
def each_file(castle, basedir, subdirs)
|
||||
absolute_basedir = Pathname.new(basedir).expand_path
|
||||
castle_home = castle_dir(castle)
|
||||
inside basedir do |destination_root|
|
||||
FileUtils.cd(destination_root) unless destination_root == FileUtils.pwd
|
||||
files = Pathname.glob('*', File::FNM_DOTMATCH)
|
||||
.reject { |a| ['.', '..'].include?(a.to_s) }
|
||||
.reject { |path| matches_ignored_dir? castle_home, path.expand_path, subdirs }
|
||||
files.each do |path|
|
||||
absolute_path = path.expand_path
|
||||
|
||||
relative_dir = absolute_basedir.relative_path_from(castle_home)
|
||||
home_path = home_dir.join(relative_dir).join(path)
|
||||
|
||||
yield(absolute_path, home_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def matches_ignored_dir?(castle_home, absolute_path, subdirs)
|
||||
# make ignore dirs
|
||||
ignore_dirs = []
|
||||
subdirs.each do |subdir|
|
||||
# ignore all parent of each line in subdir file
|
||||
Pathname.new(subdir).ascend do |p|
|
||||
ignore_dirs.push(p)
|
||||
end
|
||||
end
|
||||
|
||||
# ignore dirs written in subdir file
|
||||
ignore_dirs.uniq.each do |ignore_dir|
|
||||
return true if absolute_path == castle_home.join(ignore_dir)
|
||||
end
|
||||
false
|
||||
end
|
||||
|
||||
def configure_symlinks_diff
|
||||
# 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, source|
|
||||
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, File.binread(source)) unless destination.symlink?
|
||||
|
||||
say "- #{destination.readlink}", :red, true
|
||||
say "+ #{source.expand_path}", :green, true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
module Homesick
|
||||
# A representation of Homesick's version number in constants, including a
|
||||
# String of the entire version number
|
||||
module Version
|
||||
MAJOR = 1
|
||||
MINOR = 1
|
||||
PATCH = 3
|
||||
PATCH = 6
|
||||
|
||||
STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
||||
end
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
require 'spec_helper'
|
||||
require 'capture-output'
|
||||
require 'pathname'
|
||||
@@ -146,7 +145,7 @@ describe Homesick::CLI do
|
||||
|
||||
it 'throws an exception when trying to clone a malformed uri like malformed' do
|
||||
expect(homesick).not_to receive(:git_clone)
|
||||
expect { homesick.clone 'malformed' }.to raise_error
|
||||
expect { homesick.clone 'malformed' }.to raise_error(RuntimeError)
|
||||
end
|
||||
|
||||
it 'clones a github repo' do
|
||||
@@ -158,8 +157,8 @@ describe Homesick::CLI do
|
||||
|
||||
it 'accepts a destination', :focus do
|
||||
expect(homesick).to receive(:git_clone)
|
||||
.with('https://github.com/wfarr/dotfiles.git',
|
||||
destination: Pathname.new('other-name'))
|
||||
.with('https://github.com/wfarr/dotfiles.git',
|
||||
destination: Pathname.new('other-name'))
|
||||
|
||||
homesick.clone 'wfarr/dotfiles', 'other-name'
|
||||
end
|
||||
@@ -331,6 +330,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(&:chr).join, home: (0..255).step(30).reverse_each.map(&: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
|
||||
@@ -498,9 +531,9 @@ 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/,
|
||||
:red)
|
||||
.with(:error,
|
||||
/Could not pull castle_repo, expected .* to exist and contain dotfiles/,
|
||||
:red)
|
||||
expect { homesick.pull 'castle_repo' }.to raise_error(SystemExit)
|
||||
end
|
||||
|
||||
@@ -510,9 +543,9 @@ describe Homesick::CLI do
|
||||
given_castle('glencairn')
|
||||
allow(homesick).to receive(:system).exactly(2).times.with('git pull --quiet')
|
||||
allow(homesick).to receive(:system).exactly(2).times
|
||||
.with('git submodule --quiet init')
|
||||
.with('git submodule --quiet init')
|
||||
allow(homesick).to receive(:system).exactly(2).times
|
||||
.with('git submodule --quiet update --init --recursive >/dev/null 2>&1')
|
||||
.with('git submodule --quiet update --init --recursive >/dev/null 2>&1')
|
||||
Capture.stdout do
|
||||
Capture.stderr { homesick.invoke 'pull', [], all: true }
|
||||
end
|
||||
@@ -529,7 +562,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 +720,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
|
||||
@@ -705,18 +738,22 @@ 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
|
||||
.with(:error, 'The $EDITOR environment variable must be set to use this command', :red)
|
||||
.with(:error, 'The $EDITOR environment variable must be set to use this command', :red)
|
||||
expect { homesick.open 'castle_repo' }.to raise_error(SystemExit)
|
||||
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
|
||||
.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
|
||||
@@ -735,7 +772,7 @@ describe Homesick::CLI do
|
||||
it 'executes a single command with no arguments inside a given castle' do
|
||||
allow(homesick).to receive('inside').once.with(kind_of(Pathname)).and_yield
|
||||
allow(homesick).to receive('say_status').once
|
||||
.with(be_a(String), be_a(String), :green)
|
||||
.with(be_a(String), be_a(String), :green)
|
||||
allow(homesick).to receive('system').once.with('ls')
|
||||
Capture.stdout { homesick.exec 'castle_repo', 'ls' }
|
||||
end
|
||||
@@ -743,14 +780,14 @@ describe Homesick::CLI do
|
||||
it 'executes a single command with arguments inside a given castle' do
|
||||
allow(homesick).to receive('inside').once.with(kind_of(Pathname)).and_yield
|
||||
allow(homesick).to receive('say_status').once
|
||||
.with(be_a(String), be_a(String), :green)
|
||||
.with(be_a(String), be_a(String), :green)
|
||||
allow(homesick).to receive('system').once.with('ls -la')
|
||||
Capture.stdout { homesick.exec 'castle_repo', 'ls', '-la' }
|
||||
end
|
||||
|
||||
it 'raises an error when the method is called without a command' do
|
||||
allow(homesick).to receive('say_status').once
|
||||
.with(:error, be_a(String), :red)
|
||||
.with(:error, be_a(String), :red)
|
||||
allow(homesick).to receive('exit').once.with(1)
|
||||
Capture.stdout { homesick.exec 'castle_repo' }
|
||||
end
|
||||
@@ -758,9 +795,9 @@ describe Homesick::CLI do
|
||||
context 'pretend' do
|
||||
it 'does not execute a command when the pretend option is passed' do
|
||||
allow(homesick).to receive('say_status').once
|
||||
.with(be_a(String), match(/.*Would execute.*/), :green)
|
||||
.with(be_a(String), match(/.*Would execute.*/), :green)
|
||||
expect(homesick).to receive('system').never
|
||||
Capture.stdout { homesick.invoke 'exec', %w(castle_repo ls -la), pretend: true }
|
||||
Capture.stdout { homesick.invoke 'exec', %w[castle_repo ls -la], pretend: true }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -768,8 +805,8 @@ describe Homesick::CLI do
|
||||
it 'does not print status information when quiet is passed' do
|
||||
expect(homesick).to receive('say_status').never
|
||||
allow(homesick).to receive('system').once
|
||||
.with('ls -la')
|
||||
Capture.stdout { homesick.invoke 'exec', %w(castle_repo ls -la), quiet: true }
|
||||
.with('ls -la')
|
||||
Capture.stdout { homesick.invoke 'exec', %w[castle_repo ls -la], quiet: true }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -783,7 +820,7 @@ describe Homesick::CLI do
|
||||
it 'executes a command without arguments inside the root of each cloned castle' do
|
||||
allow(homesick).to receive('inside_each_castle').exactly(:twice).and_yield('castle_repo').and_yield('another_castle_repo')
|
||||
allow(homesick).to receive('say_status').at_least(:once)
|
||||
.with(be_a(String), be_a(String), :green)
|
||||
.with(be_a(String), be_a(String), :green)
|
||||
allow(homesick).to receive('system').at_least(:once).with('ls')
|
||||
Capture.stdout { homesick.exec_all 'ls' }
|
||||
end
|
||||
@@ -791,14 +828,14 @@ describe Homesick::CLI do
|
||||
it 'executes a command with arguments inside the root of each cloned castle' do
|
||||
allow(homesick).to receive('inside_each_castle').exactly(:twice).and_yield('castle_repo').and_yield('another_castle_repo')
|
||||
allow(homesick).to receive('say_status').at_least(:once)
|
||||
.with(be_a(String), be_a(String), :green)
|
||||
.with(be_a(String), be_a(String), :green)
|
||||
allow(homesick).to receive('system').at_least(:once).with('ls -la')
|
||||
Capture.stdout { homesick.exec_all 'ls', '-la' }
|
||||
end
|
||||
|
||||
it 'raises an error when the method is called without a command' do
|
||||
allow(homesick).to receive('say_status').once
|
||||
.with(:error, be_a(String), :red)
|
||||
.with(:error, be_a(String), :red)
|
||||
allow(homesick).to receive('exit').once.with(1)
|
||||
Capture.stdout { homesick.exec_all }
|
||||
end
|
||||
@@ -806,9 +843,9 @@ describe Homesick::CLI do
|
||||
context 'pretend' do
|
||||
it 'does not execute a command when the pretend option is passed' do
|
||||
allow(homesick).to receive('say_status').at_least(:once)
|
||||
.with(be_a(String), match(/.*Would execute.*/), :green)
|
||||
.with(be_a(String), match(/.*Would execute.*/), :green)
|
||||
expect(homesick).to receive('system').never
|
||||
Capture.stdout { homesick.invoke 'exec_all', %w(ls -la), pretend: true }
|
||||
Capture.stdout { homesick.invoke 'exec_all', %w[ls -la], pretend: true }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -816,8 +853,8 @@ describe Homesick::CLI do
|
||||
it 'does not print status information when quiet is passed' do
|
||||
expect(homesick).to receive('say_status').never
|
||||
allow(homesick).to receive('system').at_least(:once)
|
||||
.with('ls -la')
|
||||
Capture.stdout { homesick.invoke 'exec_all', %w(ls -la), quiet: true }
|
||||
.with('ls -la')
|
||||
Capture.stdout { homesick.invoke 'exec_all', %w[ls -la], quiet: true }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user