File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ def extract_ref(input)
50
50
51
51
return pair unless @project
52
52
53
+ # Remove relative_url_root from path
54
+ input . gsub! ( /^#{ Gitlab . config . gitlab . relative_url_root } / , "" )
53
55
# Remove project, actions and all other staff from path
54
56
input . gsub! ( /^\/ #{ Regexp . escape ( @project . path_with_namespace ) } / , "" )
55
57
input . gsub! ( /^\/ (tree|commits|blame|blob|refs)\/ / , "" ) # remove actions
Original file line number Diff line number Diff line change 73
73
extract_ref ( '/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG?_=12354435' ) . should == [ 'v2.0.0' , 'CHANGELOG' ]
74
74
end
75
75
end
76
+
77
+ context "with a fullpath and a relative_url_root" do
78
+ before do
79
+ Gitlab . config . gitlab . stub ( relative_url_root : '/relative' )
80
+ end
81
+
82
+ it "extracts a valid branch with relative_url_root" do
83
+ extract_ref ( '/relative/gitlab/gitlab-ci/tree/foo/bar/baz/CHANGELOG' ) . should == [ 'foo/bar/baz' , 'CHANGELOG' ]
84
+ end
85
+
86
+ it "extracts a valid tag" do
87
+ extract_ref ( '/relative/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG' ) . should == [ 'v2.0.0' , 'CHANGELOG' ]
88
+ end
89
+
90
+ it "extracts a valid commit SHA" do
91
+ extract_ref ( '/relative/gitlab/gitlab-ci/tree/f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG' ) . should ==
92
+ [ 'f4b14494ef6abf3d144c28e4af0c20143383e062' , 'CHANGELOG' ]
93
+ end
94
+
95
+ it "extracts a timestamp" do
96
+ extract_ref ( '/relative/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG?_=12354435' ) . should == [ 'v2.0.0' , 'CHANGELOG' ]
97
+ end
98
+ end
76
99
end
77
100
end
You can’t perform that action at this time.
0 commit comments