File tree Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Original file line number Diff line number Diff line change @@ -35,10 +35,10 @@ def restrict_url_to_trunk
35
35
36
36
if list . include? 'trunk/'
37
37
self . url = File . join ( self . url , 'trunk' )
38
- self . branch_name = File . join ( self . branch_name , 'trunk' ) if self . branch_name
38
+ self . branch_name = File . join ( self . branch_name , 'trunk' )
39
39
elsif list . size == 1 and list . first [ -1 ..-1 ] == '/'
40
40
self . url = File . join ( self . url , list . first [ 0 ..-2 ] )
41
- self . branch_name = File . join ( self . branch_name , list . first [ 0 ..-2 ] ) if self . branch_name
41
+ self . branch_name = File . join ( self . branch_name , list . first [ 0 ..-2 ] )
42
42
return restrict_url_to_trunk
43
43
end
44
44
self . url
Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ def normalize
12
12
super
13
13
@url = path_to_file_url ( @url )
14
14
@url = force_https_if_sourceforge ( @url )
15
- @branch_name = recalc_branch_name
15
+ if @branch_name
16
+ clean_branch_name
17
+ else
18
+ @branch_name = recalc_branch_name
19
+ end
16
20
self
17
21
end
18
22
@@ -57,11 +61,10 @@ def recalc_branch_name
57
61
begin
58
62
@branch_name = @url ? @url [ root . length ..-1 ] : @branch_name
59
63
rescue RuntimeError => exception
60
- exception . message =~ /svn:*is not a working copy/ # we have a file system
61
- @branch_name = ''
64
+ @branch_name = '' if exception . message =~ /(svn:*is not a working copy|Unable to open an ra_local session to URL)/ # we have a file system
62
65
end
63
- @branch_name = @branch_name [ 0 ..- 2 ] if @branch_name [ - 1 ..- 1 ] == '/'
64
- @branch_name
66
+ clean_branch_name
67
+ @branch_name
65
68
end
66
69
67
70
def guess_forge
@@ -74,5 +77,11 @@ def guess_forge
74
77
u
75
78
end
76
79
end
80
+
81
+ private
82
+ def clean_branch_name
83
+ return unless @branch_name
84
+ @branch_name . chop! if @branch_name . end_with? ( '/' )
85
+ end
77
86
end
78
87
end
Original file line number Diff line number Diff line change @@ -159,9 +159,18 @@ def test_recalc_branch_name
159
159
assert_equal '' , svn_trunk . branch_name
160
160
end
161
161
end
162
- end
163
162
164
- def test_strip_trailing_whack_from_branch_name
165
- assert_equal '/trunk' , SvnAdapter . new ( :branch_name => "/trunk/" ) . normalize . branch_name
163
+ def test_strip_trailing_whack_from_branch_name
164
+ with_svn_repository ( 'svn' ) do |svn |
165
+ assert_equal '/trunk' , SvnAdapter . new ( :url => svn . root , :branch_name => "/trunk/" ) . normalize . branch_name
166
+ end
167
+ end
168
+
169
+ def test_empty_branch_name_with_file_system
170
+ Scm ::ScratchDir . new do |dir |
171
+ svn = SvnAdapter . new ( :url => dir ) . normalize
172
+ assert_equal '' , svn . branch_name
173
+ end
174
+ end
166
175
end
167
176
end
You can’t perform that action at this time.
0 commit comments