homesick 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog.markdown +9 -1
- data/Rakefile +1 -1
- data/homesick.gemspec +4 -2
- data/lib/homesick.rb +12 -58
- data/lib/homesick/actions.rb +40 -0
- data/lib/homesick/shell.rb +17 -0
- metadata +6 -4
data/ChangeLog.markdown
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
+
# 2.0.0
|
2
|
+
|
3
|
+
* Better support for recognizing git urls (thanks jacobat!)
|
4
|
+
* if it looks like a github user/repo, do that
|
5
|
+
* otherwise hand off to git clone
|
6
|
+
* Listing now displays in color, and show git remote
|
7
|
+
* Support pretend, force, and quiet modes
|
8
|
+
|
1
9
|
# 0.1.1
|
2
10
|
|
3
11
|
* Fixed trying to link against castles that don't exist
|
4
12
|
* Fixed linking, which tries to exclude . and .. from the list of files to
|
5
|
-
link (thanks Martinos)
|
13
|
+
link (thanks Martinos!)
|
6
14
|
|
7
15
|
# 0.1.0
|
8
16
|
|
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem|
|
|
22
22
|
gem.email = "josh@technicalpickles.com"
|
23
23
|
gem.homepage = "http://github.com/technicalpickles/homesick"
|
24
24
|
gem.authors = ["Joshua Nichols"]
|
25
|
-
gem.version = "0.
|
25
|
+
gem.version = "0.2.0"
|
26
26
|
# Have dependencies? Add them to Gemfile
|
27
27
|
|
28
28
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
data/homesick.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{homesick}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joshua Nichols"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-19}
|
13
13
|
s.default_executable = %q{homesick}
|
14
14
|
s.description = %q{
|
15
15
|
A man’s home (directory) is his castle, so don’t leave home with out it.
|
@@ -35,6 +35,8 @@ Gem::Specification.new do |s|
|
|
35
35
|
"bin/homesick",
|
36
36
|
"homesick.gemspec",
|
37
37
|
"lib/homesick.rb",
|
38
|
+
"lib/homesick/actions.rb",
|
39
|
+
"lib/homesick/shell.rb",
|
38
40
|
"spec/homesick/homesick_spec.rb",
|
39
41
|
"spec/spec.opts",
|
40
42
|
"spec/spec_helper.rb"
|
data/lib/homesick.rb
CHANGED
@@ -1,40 +1,29 @@
|
|
1
1
|
require 'thor'
|
2
2
|
|
3
3
|
class Homesick < Thor
|
4
|
-
|
4
|
+
autoload :Shell, 'homesick/shell'
|
5
|
+
autoload :Actions, 'homesick/actions'
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
include Thor::Actions
|
8
|
+
include Homesick::Actions
|
8
9
|
|
9
|
-
|
10
|
-
destination = Pathname.new(destination)
|
10
|
+
add_runtime_options!
|
11
11
|
|
12
|
-
|
13
|
-
say "- #{destination.readlink}", :red, true
|
14
|
-
say "+ #{content.expand_path}", :green, true
|
15
|
-
else
|
16
|
-
super
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
12
|
+
GITHUB_NAME_REPO_PATTERN = /\A([A-Za-z_-]+)\/([A-Za-z_-]+)\Z/
|
21
13
|
|
22
14
|
def initialize(args=[], options={}, config={})
|
23
15
|
super
|
24
16
|
self.shell = Homesick::Shell.new
|
25
17
|
end
|
26
18
|
|
27
|
-
GIT_URI_PATTERN = /^git:\/\//
|
28
|
-
GITHUB_NAME_REPO_PATTERN = /([A-Za-z_-]+)\/([A-Za-z_-]+)/
|
29
|
-
|
30
19
|
desc "clone URI", "Clone +uri+ as a castle for homesick"
|
31
20
|
def clone(uri)
|
32
21
|
empty_directory repos_dir, :verbose => false
|
33
22
|
inside repos_dir do
|
34
|
-
if uri =~
|
23
|
+
if uri =~ GITHUB_NAME_REPO_PATTERN
|
24
|
+
git_clone "git://github.com/#{$1}/#{$2}.git", :destination => "#{$1}_#{$2}"
|
25
|
+
else
|
35
26
|
git_clone uri
|
36
|
-
elsif uri =~ GITHUB_NAME_REPO_PATTERN
|
37
|
-
git_clone "git://github.com/#{$1}/#{$2}.git", "#{$1}_#{$2}"
|
38
27
|
end
|
39
28
|
end
|
40
29
|
end
|
@@ -67,7 +56,9 @@ class Homesick < Thor
|
|
67
56
|
def list
|
68
57
|
inside repos_dir do
|
69
58
|
Pathname.glob('*') do |home|
|
70
|
-
|
59
|
+
inside home do
|
60
|
+
say_status home, `git config remote.origin.url`, :cyan
|
61
|
+
end
|
71
62
|
end
|
72
63
|
end
|
73
64
|
end
|
@@ -90,43 +81,6 @@ class Homesick < Thor
|
|
90
81
|
|
91
82
|
protected
|
92
83
|
|
93
|
-
# TODO move this to be more like thor's template, empty_directory, etc
|
94
|
-
def git_clone(repo, config = {})
|
95
|
-
config ||= {}
|
96
|
-
destination = config[:destination] || begin
|
97
|
-
repo =~ /([^\/]+)\.git$/
|
98
|
-
$1
|
99
|
-
end
|
100
|
-
|
101
|
-
destination = Pathname.new(destination) unless destination.kind_of?(Pathname)
|
102
|
-
|
103
|
-
if ! destination.directory?
|
104
|
-
say_status 'git clone', "#{repo} to #{destination.expand_path}", :green if config.fetch(:verbose, true)
|
105
|
-
system "git clone #{repo} #{destination}" unless options[:pretend]
|
106
|
-
else
|
107
|
-
say_status :exist, destination.expand_path, :blue
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def symlink(source, destination, config = {})
|
112
|
-
destination = Pathname.new(destination)
|
113
|
-
|
114
|
-
if destination.symlink?
|
115
|
-
if destination.readlink == source
|
116
|
-
say_status :identical, destination.expand_path, :blue
|
117
|
-
else
|
118
|
-
say_status :conflict, "#{destination} exists and points to #{destination.readlink}", :red
|
119
|
-
|
120
|
-
if shell.file_collision(destination) { source }
|
121
|
-
system "ln -sf #{source} #{destination}"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
else
|
125
|
-
say_status :symlink, "#{source.expand_path} to #{destination.expand_path}", :green
|
126
|
-
system "ln -s #{source} #{destination}"
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
84
|
def user_dir
|
131
85
|
self.class.user_dir
|
132
86
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Homesick
|
2
|
+
module Actions
|
3
|
+
# TODO move this to be more like thor's template, empty_directory, etc
|
4
|
+
def git_clone(repo, config = {})
|
5
|
+
config ||= {}
|
6
|
+
destination = config[:destination] || begin
|
7
|
+
repo =~ /([^\/]+)\.git$/
|
8
|
+
$1
|
9
|
+
end
|
10
|
+
|
11
|
+
destination = Pathname.new(destination) unless destination.kind_of?(Pathname)
|
12
|
+
|
13
|
+
if ! destination.directory?
|
14
|
+
say_status 'git clone', "#{repo} to #{destination.expand_path}", :green unless options[:quiet]
|
15
|
+
system "git clone -q #{repo} #{destination}" unless options[:pretend]
|
16
|
+
else
|
17
|
+
say_status :exist, destination.expand_path, :blue unless options[:quiet]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def symlink(source, destination, config = {})
|
22
|
+
destination = Pathname.new(destination)
|
23
|
+
|
24
|
+
if destination.symlink?
|
25
|
+
if destination.readlink == source
|
26
|
+
say_status :identical, destination.expand_path, :blue unless options[:quiet]
|
27
|
+
else
|
28
|
+
say_status :conflict, "#{destination} exists and points to #{destination.readlink}", :red unless options[:quiet]
|
29
|
+
|
30
|
+
if shell.file_collision(destination) { source }
|
31
|
+
system "ln -sf #{source} #{destination}" unless options[:pretend]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
else
|
35
|
+
say_status :symlink, "#{source.expand_path} to #{destination.expand_path}", :green unless options[:quiet]
|
36
|
+
system "ln -s #{source} #{destination}" unless options[:pretend]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Homesick
|
2
|
+
# Hack in support for diffing symlinks
|
3
|
+
class Shell < Thor::Shell::Color
|
4
|
+
|
5
|
+
def show_diff(destination, content)
|
6
|
+
destination = Pathname.new(destination)
|
7
|
+
|
8
|
+
if destination.symlink?
|
9
|
+
say "- #{destination.readlink}", :red, true
|
10
|
+
say "+ #{content.expand_path}", :green, true
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Joshua Nichols
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-19 00:00:00 -04:00
|
18
18
|
default_executable: homesick
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -39,6 +39,8 @@ files:
|
|
39
39
|
- bin/homesick
|
40
40
|
- homesick.gemspec
|
41
41
|
- lib/homesick.rb
|
42
|
+
- lib/homesick/actions.rb
|
43
|
+
- lib/homesick/shell.rb
|
42
44
|
- spec/homesick/homesick_spec.rb
|
43
45
|
- spec/spec.opts
|
44
46
|
- spec/spec_helper.rb
|