@@ -15,6 +15,7 @@ import {
1515test ( "parseRemoteFileAddress accepts full remote addresses" , async ( t ) => {
1616 const env = getTestEnv ( ) ;
1717
18+ // Old format.
1819 t . deepEqual ( parseRemoteFileAddress ( env , "owner/repo/path@ref" ) , {
1920 owner : "owner" ,
2021 repo : "repo" ,
@@ -86,6 +87,79 @@ test("parseRemoteFileAddress accepts full remote addresses", async (t) => {
8687 ref : "ref/feature" ,
8788 } satisfies RemoteFileAddress ,
8889 ) ;
90+
91+ // New format.
92+ t . deepEqual ( parseRemoteFileAddress ( env , "owner/repo@ref:path" ) , {
93+ owner : "owner" ,
94+ repo : "repo" ,
95+ path : "path" ,
96+ ref : "ref" ,
97+ } satisfies RemoteFileAddress ) ;
98+
99+ t . deepEqual ( parseRemoteFileAddress ( env , "owner /repo@ref:path" ) , {
100+ owner : "owner" ,
101+ repo : "repo" ,
102+ path : "path" ,
103+ ref : "ref" ,
104+ } satisfies RemoteFileAddress ) ;
105+
106+ t . deepEqual ( parseRemoteFileAddress ( env , "owner/ repo@ref:path" ) , {
107+ owner : "owner" ,
108+ repo : "repo" ,
109+ path : "path" ,
110+ ref : "ref" ,
111+ } satisfies RemoteFileAddress ) ;
112+
113+ t . deepEqual ( parseRemoteFileAddress ( env , "owner/repo @ref:path" ) , {
114+ owner : "owner" ,
115+ repo : "repo" ,
116+ path : "path" ,
117+ ref : "ref" ,
118+ } satisfies RemoteFileAddress ) ;
119+
120+ t . deepEqual ( parseRemoteFileAddress ( env , "owner/repo@ ref:path" ) , {
121+ owner : "owner" ,
122+ repo : "repo" ,
123+ path : "path" ,
124+ ref : "ref" ,
125+ } satisfies RemoteFileAddress ) ;
126+
127+ t . deepEqual ( parseRemoteFileAddress ( env , "owner/repo@ref :path" ) , {
128+ owner : "owner" ,
129+ repo : "repo" ,
130+ path : "path" ,
131+ ref : "ref" ,
132+ } satisfies RemoteFileAddress ) ;
133+
134+ t . deepEqual ( parseRemoteFileAddress ( env , "owner/repo@ref: path" ) , {
135+ owner : "owner" ,
136+ repo : "repo" ,
137+ path : "path" ,
138+ ref : "ref" ,
139+ } satisfies RemoteFileAddress ) ;
140+
141+ t . deepEqual (
142+ parseRemoteFileAddress ( env , "owner/repo@ref/feature:path/to/codeql.yml" ) ,
143+ {
144+ owner : "owner" ,
145+ repo : "repo" ,
146+ path : "path/to/codeql.yml" ,
147+ ref : "ref/feature" ,
148+ } satisfies RemoteFileAddress ,
149+ ) ;
150+
151+ t . deepEqual (
152+ parseRemoteFileAddress (
153+ env ,
154+ " owner/repo@ref/feature:path/to/codeql.yml " ,
155+ ) ,
156+ {
157+ owner : "owner" ,
158+ repo : "repo" ,
159+ path : "path/to/codeql.yml" ,
160+ ref : "ref/feature" ,
161+ } satisfies RemoteFileAddress ,
162+ ) ;
89163} ) ;
90164
91165test ( "parseRemoteFileAddress accepts remote address without an owner" , async ( t ) => {
@@ -96,13 +170,27 @@ test("parseRemoteFileAddress accepts remote address without an owner", async (t)
96170 . withArgs ( ActionsEnvVars . GITHUB_REPOSITORY )
97171 . returns ( `${ owner } /current-repo` ) ;
98172
173+ t . deepEqual ( parseRemoteFileAddress ( env , "repo@ref:path.yml" ) , {
174+ owner,
175+ repo : "repo" ,
176+ path : "path.yml" ,
177+ ref : "ref" ,
178+ } satisfies RemoteFileAddress ) ;
179+
99180 t . deepEqual ( parseRemoteFileAddress ( env , "repo@ref" ) , {
100181 owner,
101182 repo : "repo" ,
102183 path : DEFAULT_CONFIG_FILE_NAME ,
103184 ref : "ref" ,
104185 } satisfies RemoteFileAddress ) ;
105186
187+ t . deepEqual ( parseRemoteFileAddress ( env , "repo:path.yml" ) , {
188+ owner,
189+ repo : "repo" ,
190+ path : "path.yml" ,
191+ ref : DEFAULT_CONFIG_FILE_REF ,
192+ } satisfies RemoteFileAddress ) ;
193+
106194 t . deepEqual ( parseRemoteFileAddress ( env , "repo" ) , {
107195 owner,
108196 repo : "repo" ,
@@ -142,14 +230,7 @@ test("parseRemoteFileAddress accepts remote address without a path", async (t) =
142230test ( "parseRemoteFileAddress accepts remote address without a ref" , async ( t ) => {
143231 const env = getTestEnv ( ) ;
144232
145- t . deepEqual ( parseRemoteFileAddress ( env , "owner/repo/path" ) , {
146- owner : "owner" ,
147- repo : "repo" ,
148- path : "path" ,
149- ref : DEFAULT_CONFIG_FILE_REF ,
150- } satisfies RemoteFileAddress ) ;
151-
152- t . deepEqual ( parseRemoteFileAddress ( env , "owner/repo/path@" ) , {
233+ t . deepEqual ( parseRemoteFileAddress ( env , "owner/repo:path" ) , {
153234 owner : "owner" ,
154235 repo : "repo" ,
155236 path : "path" ,
@@ -171,10 +252,43 @@ test("parseRemoteFileAddress rejects invalid values", async (t) => {
171252 t . throws ( ( ) => parseRemoteFileAddress ( env , "repo//absolute" ) , {
172253 instanceOf : ConfigurationError ,
173254 } ) ;
255+ t . throws ( ( ) => parseRemoteFileAddress ( env , "repo:/absolute" ) , {
256+ instanceOf : ConfigurationError ,
257+ } ) ;
174258 t . throws ( ( ) => parseRemoteFileAddress ( env , "/repo@ref" ) , {
175259 instanceOf : ConfigurationError ,
176260 } ) ;
177261 t . throws ( ( ) => parseRemoteFileAddress ( env , " /repo@ref" ) , {
178262 instanceOf : ConfigurationError ,
179263 } ) ;
264+ t . throws ( ( ) => parseRemoteFileAddress ( env , "repo@" ) , {
265+ instanceOf : ConfigurationError ,
266+ } ) ;
267+ t . throws ( ( ) => parseRemoteFileAddress ( env , "repo:" ) , {
268+ instanceOf : ConfigurationError ,
269+ } ) ;
270+ t . throws ( ( ) => parseRemoteFileAddress ( env , "repo/" ) , {
271+ instanceOf : ConfigurationError ,
272+ } ) ;
273+ t . throws ( ( ) => parseRemoteFileAddress ( env , "/repo" ) , {
274+ instanceOf : ConfigurationError ,
275+ } ) ;
276+ t . throws ( ( ) => parseRemoteFileAddress ( env , ":path" ) , {
277+ instanceOf : ConfigurationError ,
278+ } ) ;
279+ t . throws ( ( ) => parseRemoteFileAddress ( env , "@ref" ) , {
280+ instanceOf : ConfigurationError ,
281+ } ) ;
282+ t . throws ( ( ) => parseRemoteFileAddress ( env , "@ref:path" ) , {
283+ instanceOf : ConfigurationError ,
284+ } ) ;
285+ t . throws ( ( ) => parseRemoteFileAddress ( env , "owner/@ref:path" ) , {
286+ instanceOf : ConfigurationError ,
287+ } ) ;
288+ t . throws ( ( ) => parseRemoteFileAddress ( env , "owner/@ref" ) , {
289+ instanceOf : ConfigurationError ,
290+ } ) ;
291+ t . throws ( ( ) => parseRemoteFileAddress ( env , "owner/:path" ) , {
292+ instanceOf : ConfigurationError ,
293+ } ) ;
180294} ) ;
0 commit comments