piston 1.4.0 → 2.0.1
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/History.txt +24 -0
- data/License.txt +20 -0
- data/Manifest.txt +109 -0
- data/{README → README.txt} +14 -10
- data/VERSION.yml +4 -0
- data/bin/piston +3 -8
- data/lib/piston/cli.rb +121 -0
- data/lib/piston/commands/base.rb +44 -0
- data/lib/piston/commands/convert.rb +23 -71
- data/lib/piston/commands/diff.rb +14 -46
- data/lib/piston/commands/import.rb +48 -57
- data/lib/piston/commands/info.rb +24 -0
- data/lib/piston/commands/lock_unlock.rb +26 -0
- data/lib/piston/commands/status.rb +29 -54
- data/lib/piston/commands/update.rb +35 -122
- data/lib/piston/commands/upgrade.rb +26 -0
- data/lib/piston/commands.rb +4 -0
- data/lib/piston/git/client.rb +76 -0
- data/lib/piston/git/commit.rb +114 -0
- data/lib/piston/git/repository.rb +63 -0
- data/lib/piston/git/working_copy.rb +145 -0
- data/lib/piston/git.rb +13 -0
- data/lib/piston/repository.rb +61 -0
- data/lib/piston/revision.rb +83 -0
- data/lib/piston/svn/client.rb +88 -0
- data/lib/piston/svn/repository.rb +67 -0
- data/lib/piston/svn/revision.rb +112 -0
- data/lib/piston/svn/working_copy.rb +184 -0
- data/lib/piston/svn.rb +15 -0
- data/lib/piston/version.rb +9 -7
- data/lib/piston/working_copy.rb +334 -0
- data/lib/piston.rb +13 -64
- data/lib/subclass_responsibility_error.rb +2 -0
- data/test/integration_helpers.rb +36 -0
- data/test/spec_suite.rb +4 -0
- data/test/test_helper.rb +92 -0
- data/test/unit/git/commit/test_checkout.rb +31 -0
- data/test/unit/git/commit/test_each.rb +30 -0
- data/test/unit/git/commit/test_rememberance.rb +22 -0
- data/test/unit/git/commit/test_validation.rb +34 -0
- data/test/unit/git/repository/test_at.rb +23 -0
- data/test/unit/git/repository/test_basename.rb +12 -0
- data/test/unit/git/repository/test_branchanme.rb +15 -0
- data/test/unit/git/repository/test_guessing.rb +32 -0
- data/test/unit/git/working_copy/test_copying.rb +25 -0
- data/test/unit/git/working_copy/test_creation.rb +22 -0
- data/test/unit/git/working_copy/test_existence.rb +18 -0
- data/test/unit/git/working_copy/test_finalization.rb +15 -0
- data/test/unit/git/working_copy/test_guessing.rb +35 -0
- data/test/unit/git/working_copy/test_rememberance.rb +22 -0
- data/test/unit/svn/repository/test_at.rb +19 -0
- data/test/unit/svn/repository/test_basename.rb +24 -0
- data/test/unit/svn/repository/test_guessing.rb +45 -0
- data/test/unit/svn/revision/test_checkout.rb +28 -0
- data/test/unit/svn/revision/test_each.rb +22 -0
- data/test/unit/svn/revision/test_rememberance.rb +38 -0
- data/test/unit/svn/revision/test_validation.rb +50 -0
- data/test/unit/svn/working_copy/test_copying.rb +26 -0
- data/test/unit/svn/working_copy/test_creation.rb +16 -0
- data/test/unit/svn/working_copy/test_existence.rb +23 -0
- data/test/unit/svn/working_copy/test_externals.rb +56 -0
- data/test/unit/svn/working_copy/test_finalization.rb +17 -0
- data/test/unit/svn/working_copy/test_guessing.rb +18 -0
- data/test/unit/svn/working_copy/test_rememberance.rb +26 -0
- data/test/unit/test_info.rb +37 -0
- data/test/unit/test_lock_unlock.rb +47 -0
- data/test/unit/test_repository.rb +51 -0
- data/test/unit/test_revision.rb +31 -0
- data/test/unit/working_copy/test_guessing.rb +35 -0
- data/test/unit/working_copy/test_info.rb +14 -0
- data/test/unit/working_copy/test_rememberance.rb +42 -0
- data/test/unit/working_copy/test_validate.rb +63 -0
- metadata +132 -31
- data/CHANGELOG +0 -81
- data/LICENSE +0 -19
- data/Rakefile +0 -63
- data/contrib/piston +0 -43
- data/lib/core_ext/range.rb +0 -5
- data/lib/core_ext/string.rb +0 -9
- data/lib/piston/command.rb +0 -68
- data/lib/piston/command_error.rb +0 -6
- data/lib/piston/commands/lock.rb +0 -30
- data/lib/piston/commands/switch.rb +0 -139
- data/lib/piston/commands/unlock.rb +0 -29
- data/lib/transat/parser.rb +0 -189
@@ -1,29 +0,0 @@
|
|
1
|
-
require "piston"
|
2
|
-
require "piston/command"
|
3
|
-
|
4
|
-
module Piston
|
5
|
-
module Commands
|
6
|
-
class Unlock < Piston::Command
|
7
|
-
def run
|
8
|
-
raise Piston::CommandError, "No targets to run against" if args.empty?
|
9
|
-
svn :propdel, Piston::LOCKED, *args
|
10
|
-
args.each do |dir|
|
11
|
-
logging_stream.puts "Unlocked '#{dir}'"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.help
|
16
|
-
"Undoes the changes enabled by lock"
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.detailed_help
|
20
|
-
<<EOF
|
21
|
-
usage: unlock DIR [DIR [...]]
|
22
|
-
|
23
|
-
Unlocked folders are free to be updated to the latest revision when
|
24
|
-
updating.
|
25
|
-
EOF
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/transat/parser.rb
DELETED
@@ -1,189 +0,0 @@
|
|
1
|
-
require "optparse"
|
2
|
-
|
3
|
-
module Transat
|
4
|
-
class VersionNeeded < StandardError; end
|
5
|
-
|
6
|
-
class HelpNeeded < StandardError
|
7
|
-
attr_reader :command
|
8
|
-
|
9
|
-
def initialize(command)
|
10
|
-
@command = command
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class NoCommandGiven < StandardError
|
15
|
-
def message
|
16
|
-
"No command given"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class UnknownOptions < StandardError
|
21
|
-
attr_reader :command
|
22
|
-
|
23
|
-
def initialize(command, unrecognized_options)
|
24
|
-
@command, @unrecognized_options = command, unrecognized_options
|
25
|
-
end
|
26
|
-
|
27
|
-
def message
|
28
|
-
"Command #{@command} does not accept options #{@unrecognized_options.join(", ")}"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class UnknownCommand < StandardError
|
33
|
-
def initialize(command, parser)
|
34
|
-
@command, @parser = command, parser
|
35
|
-
end
|
36
|
-
|
37
|
-
def message
|
38
|
-
"Unknown command: #{@command.inspect}"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class BaseCommand
|
43
|
-
attr_reader :non_options, :options
|
44
|
-
def initialize(non_options, options)
|
45
|
-
@non_options, @options = non_options, options
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class VersionCommand < BaseCommand
|
50
|
-
def run
|
51
|
-
raise VersionNeeded
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
class HelpCommand < BaseCommand
|
56
|
-
def run
|
57
|
-
raise HelpNeeded.new(non_options.first)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
class Parser
|
62
|
-
def initialize(&block)
|
63
|
-
@valid_options, @received_options, @commands = [], {}, {}
|
64
|
-
@option_parser = OptionParser.new
|
65
|
-
|
66
|
-
command(:help, Transat::HelpCommand)
|
67
|
-
command(:version, Transat::VersionCommand)
|
68
|
-
instance_eval(&block) if block_given?
|
69
|
-
end
|
70
|
-
|
71
|
-
def option(name, options={})
|
72
|
-
options[:long] = name.to_s.gsub("_", "-") unless options[:long]
|
73
|
-
@valid_options << name
|
74
|
-
@received_options[name] = nil
|
75
|
-
|
76
|
-
opt_args = []
|
77
|
-
opt_args << "-#{options[:short]}" if options.has_key?(:short)
|
78
|
-
opt_args << "--#{options[:long] || name}"
|
79
|
-
opt_args << "=#{options[:param_name]}" if options.has_key?(:param_name)
|
80
|
-
opt_args << options[:message]
|
81
|
-
case options[:type]
|
82
|
-
when :int, :integer
|
83
|
-
opt_args << Integer
|
84
|
-
when :float
|
85
|
-
opt_args << Float
|
86
|
-
when nil
|
87
|
-
# NOP
|
88
|
-
else
|
89
|
-
raise ArgumentError, "Option #{name} has a bad :type parameter: #{options[:type].inspect}"
|
90
|
-
end
|
91
|
-
|
92
|
-
@option_parser.on(*opt_args.compact) do |value|
|
93
|
-
@received_options[name] = value
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def command(name, klass, options={})
|
98
|
-
@commands[name.to_s] = options.merge(:class => klass)
|
99
|
-
end
|
100
|
-
|
101
|
-
def parse_and_execute(args=ARGV)
|
102
|
-
begin
|
103
|
-
command, non_options = parse(args)
|
104
|
-
execute(command, non_options)
|
105
|
-
rescue HelpNeeded
|
106
|
-
$stderr.puts usage($!.command)
|
107
|
-
exit 1
|
108
|
-
rescue VersionNeeded
|
109
|
-
puts "#{program_name} #{version}"
|
110
|
-
exit 0
|
111
|
-
rescue NoCommandGiven, UnknownOptions, UnknownCommand
|
112
|
-
$stderr.puts "ERROR: #{$!.message}"
|
113
|
-
$stderr.puts usage($!.respond_to?(:command) ? $!.command : nil)
|
114
|
-
exit 1
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def parse(args)
|
119
|
-
non_options = @option_parser.parse(args)
|
120
|
-
command = non_options.shift
|
121
|
-
raise NoCommandGiven unless command
|
122
|
-
return command, non_options
|
123
|
-
end
|
124
|
-
|
125
|
-
def execute(command, non_options)
|
126
|
-
found = false
|
127
|
-
@commands.each do |command_name, options|
|
128
|
-
command_klass = options[:class]
|
129
|
-
aliases = [command_name]
|
130
|
-
aliases += command_klass.aliases if command_klass.respond_to?(:aliases)
|
131
|
-
return command_klass.new(non_options, @received_options).run if aliases.include?(command)
|
132
|
-
end
|
133
|
-
|
134
|
-
raise UnknownCommand.new(command, self)
|
135
|
-
end
|
136
|
-
|
137
|
-
def usage(command=nil)
|
138
|
-
message = []
|
139
|
-
|
140
|
-
if command then
|
141
|
-
command_klass = @commands[command][:class]
|
142
|
-
help =
|
143
|
-
if command_klass.respond_to?(:aliases) then
|
144
|
-
"#{command} (#{command_klass.aliases.join(", ")})"
|
145
|
-
else
|
146
|
-
"#{command}"
|
147
|
-
end
|
148
|
-
help = "#{help}: #{command_klass.help}" if command_klass.respond_to?(:help)
|
149
|
-
message << help
|
150
|
-
message << command_klass.detailed_help if command_klass.respond_to?(:detailed_help)
|
151
|
-
message << ""
|
152
|
-
message << "Valid options:"
|
153
|
-
@option_parser.summarize(message)
|
154
|
-
else
|
155
|
-
message << "usage: #{program_name.downcase} <SUBCOMMAND> [OPTIONS] [ARGS...]"
|
156
|
-
message << "Type '#{program_name.downcase} help <SUBCOMMAND>' for help on a specific subcommand."
|
157
|
-
message << "Type '#{program_name.downcase} version' to get this program's version."
|
158
|
-
message << ""
|
159
|
-
message << "Available subcommands are:"
|
160
|
-
@commands.sort.each do |command, options|
|
161
|
-
command_klass = options[:class]
|
162
|
-
if command_klass.respond_to?(:aliases) then
|
163
|
-
message << " #{command} (#{command_klass.aliases.join(", ")})"
|
164
|
-
else
|
165
|
-
message << " #{command}"
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
message.map {|line| line.chomp}.join("\n")
|
171
|
-
end
|
172
|
-
|
173
|
-
def program_name(value=nil)
|
174
|
-
value ? @program_name = value : @program_name
|
175
|
-
end
|
176
|
-
|
177
|
-
def version(value=nil)
|
178
|
-
if value then
|
179
|
-
@version = value.respond_to?(:join) ? value.join(".") : value
|
180
|
-
else
|
181
|
-
@version
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
def self.parse_and_execute(args=ARGV, &block)
|
186
|
-
self.new(&block).parse_and_execute(args)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|