reposh 0.1.6 → 0.1.8
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/Rakefile +44 -0
- data/VERSION +1 -0
- data/bin/reposh +6 -1
- data/lib/reposh.rb +23 -10
- data/spec_reposh.rb +92 -0
- metadata +36 -19
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#
|
2
|
+
# Rakefile to creating gems
|
3
|
+
#
|
4
|
+
# configurations:
|
5
|
+
PROJECT_NAME = File.basename(File.dirname(__FILE__))
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'jeweler'
|
9
|
+
rescue LoadError
|
10
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
11
|
+
end
|
12
|
+
|
13
|
+
Jeweler::Tasks.new do |gemspec|
|
14
|
+
gemspec.name = "#{PROJECT_NAME}"
|
15
|
+
gemspec.summary = "Simple shell for VCS(Version Controll System)s like svn, hg, git, etc."
|
16
|
+
gemspec.email = "yutaka.hara/at/gmail.com"
|
17
|
+
gemspec.homepage = "http://github.com/yhara/#{PROJECT_NAME}"
|
18
|
+
gemspec.description = gemspec.summary
|
19
|
+
gemspec.authors = ["Yutaka HARA"]
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "install current source as a gem"
|
23
|
+
task :dogfood => [:gemspec, :build] do
|
24
|
+
sh "sudo gem install pkg/#{PROJECT_NAME}-#{File.read("VERSION").chomp}.gem"
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "uninstall the installed gem"
|
28
|
+
task :undogfood do
|
29
|
+
sh "sudo gem uninstall #{PROJECT_NAME}"
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "uninstall, then install current source as gem"
|
33
|
+
task :redogfood => [:undogfood, :dogfood]
|
34
|
+
|
35
|
+
desc "uninstall temporary gem and install from github"
|
36
|
+
task :nodogfood do
|
37
|
+
sh "sudo gem uninstall #{PROJECT_NAME}"
|
38
|
+
sh "sudo gem install yhara-#{PROJECT_NAME}"
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "check for gem to be built"
|
42
|
+
task :stalk do
|
43
|
+
sh "gemstalk yhara #{PROJECT_NAME}"
|
44
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.8
|
data/bin/reposh
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# reposh.rb - Reposh - Simple VCS Manager Shell
|
3
3
|
|
4
|
-
|
4
|
+
if File.symlink?(__FILE__)
|
5
|
+
$LOAD_PATH << File.join(File.dirname(File.readlink(__FILE__)), '../lib')
|
6
|
+
else
|
7
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '../lib')
|
8
|
+
end
|
9
|
+
|
5
10
|
require 'reposh'
|
6
11
|
Reposh.new.run
|
data/lib/reposh.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'readline'
|
2
2
|
require 'yaml'
|
3
3
|
require 'optparse'
|
4
|
+
require 'pathname'
|
4
5
|
|
5
6
|
class Hash
|
6
7
|
def recursive_merge(other)
|
@@ -16,7 +17,7 @@ class Hash
|
|
16
17
|
end
|
17
18
|
|
18
19
|
class Reposh
|
19
|
-
VERSION =
|
20
|
+
VERSION = File.read(Pathname(__FILE__).dirname + "../VERSION").chomp
|
20
21
|
CONF_DEFAULT = {
|
21
22
|
"global" => {
|
22
23
|
"editing_mode" => nil,
|
@@ -80,6 +81,7 @@ class Reposh
|
|
80
81
|
def load_config(path)
|
81
82
|
if File.exist?(path)
|
82
83
|
config_hash = YAML.load(File.read(path))
|
84
|
+
puts "loaded config file: #{path}"
|
83
85
|
CONF_DEFAULT.recursive_merge(config_hash)
|
84
86
|
else
|
85
87
|
CONF_DEFAULT
|
@@ -87,15 +89,24 @@ class Reposh
|
|
87
89
|
end
|
88
90
|
|
89
91
|
def guess_system
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
92
|
+
base = Pathname(Dir.pwd)
|
93
|
+
loop do
|
94
|
+
case
|
95
|
+
when (base + ".git").directory?
|
96
|
+
return "git"
|
97
|
+
when (base + ".hg").directory?
|
98
|
+
return "hg"
|
99
|
+
when (base + "_darcs").directory?
|
100
|
+
return "darcs"
|
101
|
+
when (base + ".svn").directory?
|
102
|
+
return "svn"
|
103
|
+
end
|
104
|
+
|
105
|
+
if base.root?
|
106
|
+
return "svk"
|
107
|
+
else
|
108
|
+
base = base.parent
|
109
|
+
end
|
99
110
|
end
|
100
111
|
end
|
101
112
|
|
@@ -207,11 +218,13 @@ class Reposh
|
|
207
218
|
end
|
208
219
|
end
|
209
220
|
|
221
|
+
#require 'shell'
|
210
222
|
def execute(cmd)
|
211
223
|
stat = false
|
212
224
|
([""] + @pathext).each do |ext|
|
213
225
|
command = add_ext(cmd, ext)
|
214
226
|
puts command if @trace_mode
|
227
|
+
#result = Shell.new.system(command) > $stdout
|
215
228
|
result = system(command)
|
216
229
|
return if result
|
217
230
|
stat = $?
|
data/spec_reposh.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
#
|
2
|
+
# spec_reposh.rb - Unit test for Reposh
|
3
|
+
#
|
4
|
+
# you need RSpec and Kagemusha to run this.
|
5
|
+
# gem install rspec
|
6
|
+
# gem install kagemusha
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'kagemusha'
|
10
|
+
require './lib/reposh'
|
11
|
+
|
12
|
+
describe "Hash#recursive_merge" do
|
13
|
+
before :all do
|
14
|
+
@reposh = Reposh.new
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should merge non-nested hash" do
|
18
|
+
default = {:a => 1, :b => 2}
|
19
|
+
config = {:b => 3, :c => 4}
|
20
|
+
|
21
|
+
merged = default.recursive_merge(config)
|
22
|
+
merged.should == {:a => 1, :b => 3, :c => 4}
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should merge nested hash" do
|
26
|
+
default = {:a => {"foo" => 1}, :b => {"bar" => 2, "baz" => 3}}
|
27
|
+
config = {:b => {"baz" => 4}}
|
28
|
+
|
29
|
+
merged = default.recursive_merge(config)
|
30
|
+
merged.should == {:a => {"foo" => 1},
|
31
|
+
:b => {"bar" => 2, "baz" => 4}}
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should merge triple nested hash" do
|
35
|
+
default = {:a => {"foo" => 1},
|
36
|
+
:b => {:c => {"bar" => 2, "baz" => 3}}}
|
37
|
+
config = {:b => {:c => {"baz" => 4}}}
|
38
|
+
|
39
|
+
merged = default.recursive_merge(config)
|
40
|
+
merged.should == {:a => {"foo" => 1},
|
41
|
+
:b => {:c => {"bar" => 2, "baz" => 4}}}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "Reposh::Commands" do
|
46
|
+
before :each do
|
47
|
+
@commands = Reposh::Commands.new("svn", "status", [])
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should judge whether a command matches a pattern" do
|
51
|
+
@commands.match?("exit", "exit").should == true
|
52
|
+
match = @commands.match?(/:(.*)/, ":rake aaa")
|
53
|
+
match.should be_an_instance_of(MatchData)
|
54
|
+
match[1].should == "rake aaa"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should register a command and dispatch" do
|
58
|
+
@commands.register(/foo (.*) (\d+)/){|match|
|
59
|
+
match[1].should == "bar"
|
60
|
+
match[2].should == "1192"
|
61
|
+
}
|
62
|
+
@commands.dispatch("foo bar 1192", "svk")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should dispatch only for wanted systems" do
|
66
|
+
@commands.register("foo"){ :no_match }
|
67
|
+
@commands.register("foo", ["svn", "svk"]){ :match }
|
68
|
+
|
69
|
+
@commands.dispatch("foo", "svn").should == :match
|
70
|
+
@commands.dispatch("foo", "svk").should == :match
|
71
|
+
@commands.dispatch("foo", "hg").should == :no_match
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should register custom commands" do
|
75
|
+
my_execute = Kagemusha.new(Reposh::Commands).def(:execute){|x| x}
|
76
|
+
|
77
|
+
@commands.register_custom_commands([
|
78
|
+
{ "pattern" => "ignore (\\S+)",
|
79
|
+
"rule" => "{system} propset svn:ignore . {$1}",
|
80
|
+
"for" => "svn, svk" }
|
81
|
+
])
|
82
|
+
my_execute.swap{
|
83
|
+
result = @commands.dispatch("ignore *.swp", "svn")
|
84
|
+
result.should == "svn propset svn:ignore . *.swp"
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should add extname after executable name" do
|
89
|
+
@commands.add_ext("rake stats", ".bat").should == "rake.bat stats"
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
metadata
CHANGED
@@ -1,56 +1,73 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reposh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 11
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
|
-
-
|
13
|
+
- Yutaka HARA
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
18
|
+
date: 2010-06-21 00:00:00 +09:00
|
19
|
+
default_executable: reposh
|
14
20
|
dependencies: []
|
15
21
|
|
16
|
-
description:
|
17
|
-
email:
|
22
|
+
description: Simple shell for VCS(Version Controll System)s like svn, hg, git, etc.
|
23
|
+
email: yutaka.hara/at/gmail.com
|
18
24
|
executables:
|
19
25
|
- reposh
|
20
26
|
extensions: []
|
21
27
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README
|
24
30
|
files:
|
25
31
|
- README
|
26
|
-
-
|
32
|
+
- Rakefile
|
33
|
+
- VERSION
|
27
34
|
- bin/reposh
|
28
35
|
- lib/reposh.rb
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
36
|
+
- sample.reposh.yaml
|
37
|
+
- spec_reposh.rb
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/yhara/reposh
|
40
|
+
licenses: []
|
33
41
|
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options:
|
44
|
+
- --charset=UTF-8
|
34
45
|
require_paths:
|
35
46
|
- lib
|
36
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
37
49
|
requirements:
|
38
50
|
- - ">="
|
39
51
|
- !ruby/object:Gem::Version
|
52
|
+
hash: 3
|
53
|
+
segments:
|
54
|
+
- 0
|
40
55
|
version: "0"
|
41
|
-
version:
|
42
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
43
58
|
requirements:
|
44
59
|
- - ">="
|
45
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
46
64
|
version: "0"
|
47
|
-
version:
|
48
65
|
requirements: []
|
49
66
|
|
50
|
-
rubyforge_project:
|
51
|
-
rubygems_version: 1.
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.3.7
|
52
69
|
signing_key:
|
53
|
-
specification_version:
|
54
|
-
summary: Simple VCS
|
70
|
+
specification_version: 3
|
71
|
+
summary: Simple shell for VCS(Version Controll System)s like svn, hg, git, etc.
|
55
72
|
test_files: []
|
56
73
|
|