perforce 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/perforce.rb +27 -11
- data/perforce.gemspec +1 -1
- data/test/test_main.rb +8 -2
- metadata +2 -2
data/lib/perforce.rb
CHANGED
@@ -163,11 +163,11 @@ class Perforce
|
|
163
163
|
def root
|
164
164
|
dir = run(*%w(client -o)).first["Root"]
|
165
165
|
if CYGWIN
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
166
|
+
Util.unix_path(dir).tap { |unix_dir|
|
167
|
+
if dir != unix_dir
|
168
|
+
add_unix_root
|
169
|
+
end
|
170
|
+
}
|
171
171
|
else
|
172
172
|
dir
|
173
173
|
end
|
@@ -198,13 +198,28 @@ class Perforce
|
|
198
198
|
#
|
199
199
|
# Change working directory (locally and remotely).
|
200
200
|
#
|
201
|
+
# If a block is given, the original working directory is restored
|
202
|
+
# when the block exits. (Behavior is like Dir.chdir.)
|
203
|
+
#
|
201
204
|
def chdir(dir)
|
202
205
|
previous_dir = File.expand_path(".")
|
203
|
-
|
206
|
+
|
207
|
+
Dir.chdir(dir)
|
208
|
+
begin
|
204
209
|
@p4.cwd = File.expand_path(".")
|
205
|
-
|
206
|
-
|
207
|
-
|
210
|
+
rescue
|
211
|
+
Dir.chdir(previous_dir)
|
212
|
+
raise
|
213
|
+
end
|
214
|
+
|
215
|
+
if block_given?
|
216
|
+
begin
|
217
|
+
yield dir
|
218
|
+
ensure
|
219
|
+
Dir.chdir(previous_dir)
|
220
|
+
@p4.cwd = previous_dir
|
221
|
+
end
|
222
|
+
end
|
208
223
|
end
|
209
224
|
|
210
225
|
#
|
@@ -231,8 +246,9 @@ class Perforce
|
|
231
246
|
if CYGWIN
|
232
247
|
begin
|
233
248
|
go.call
|
234
|
-
rescue P4Exception
|
235
|
-
if @p4.connected?
|
249
|
+
rescue P4Exception => exception
|
250
|
+
if @p4.connected? and
|
251
|
+
exception.message =~ %r!not under client\'s root!
|
236
252
|
# maybe unix root is not present; try again
|
237
253
|
add_unix_root
|
238
254
|
go.call
|
data/perforce.gemspec
CHANGED
data/test/test_main.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James M. Lawrence
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-08 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|