@@ -174,6 +174,8 @@ resolve_remote_pkg <- function(pkg_ref, cache_path = NULL) {
174174# ' @return List with components: type, user, repo, ref, subdir
175175# ' @keywords internal
176176parse_remote_ref <- function (ref ) {
177+ original_ref <- ref
178+
177179 # Handle web URLs
178180 if (grepl(" ^https?://" , ref )) {
179181 return (parse_remote_url(ref ))
@@ -200,7 +202,7 @@ parse_remote_ref <- function(ref) {
200202 repo = NA_character_ ,
201203 ref = NULL ,
202204 subdir = NULL ,
203- original = ref
205+ original = original_ref
204206 ))
205207 }
206208
@@ -226,7 +228,7 @@ parse_remote_ref <- function(ref) {
226228 repo = ref ,
227229 ref = commit_ref ,
228230 subdir = NULL ,
229- original = ref
231+ original = original_ref
230232 ))
231233 }
232234
@@ -262,7 +264,7 @@ parse_remote_ref <- function(ref) {
262264 repo = ref ,
263265 ref = commit_ref ,
264266 subdir = NULL ,
265- original = ref
267+ original = original_ref
266268 ))
267269 }
268270
@@ -281,7 +283,7 @@ parse_remote_ref <- function(ref) {
281283 repo = repo ,
282284 ref = commit_ref ,
283285 subdir = subdir ,
284- original = ref
286+ original = original_ref
285287 )
286288}
287289
@@ -299,33 +301,65 @@ build_pak_remote_ref <- function(parsed) {
299301 if (! is.null(parsed $ subdir )) {
300302 ref <- paste0(ref , " /" , parsed $ subdir )
301303 }
304+ if (! is.null(parsed $ ref )) {
305+ ref <- paste0(ref , " @" , parsed $ ref )
306+ }
302307 ref
303308 },
304309 gitlab = {
305310 ref <- sprintf(" gitlab::%s/%s" , parsed $ user , parsed $ repo )
306311 if (! is.null(parsed $ subdir )) {
307312 ref <- paste0(ref , " /-/" , parsed $ subdir )
308313 }
314+ if (! is.null(parsed $ ref )) {
315+ ref <- paste0(ref , " @" , parsed $ ref )
316+ }
317+ ref
318+ },
319+ bioc = {
320+ # bioc:: refs are built from repo and ref to ensure correctness
321+ # even if original was missing the prefix.
322+ ref <- sprintf(" bioc::%s" , parsed $ repo )
323+ if (! is.null(parsed $ ref )) {
324+ ref <- paste0(ref , " @" , parsed $ ref )
325+ }
309326 ref
310327 },
311- bioc = sprintf(" bioc::%s" , parsed $ repo ),
312- git = sprintf(" git::%s" , parsed $ original ),
328+ git = {
329+ # For git:: we just use the original untouched string if it has the prefix
330+ if (grepl(" ^git::" , parsed $ original )) {
331+ parsed $ original
332+ } else {
333+ ref <- sprintf(" git::%s" , parsed $ original )
334+ if (! is.null(parsed $ ref )) {
335+ ref <- paste0(ref , " @" , parsed $ ref )
336+ }
337+ ref
338+ }
339+ },
313340 bitbucket = {
314341 # Backward compatibility: translate bitbucket:: to git:: URL
315342 ref <- sprintf(" git::https://bitbucket.org/%s/%s.git" , parsed $ user , parsed $ repo )
316343 if (! is.null(parsed $ subdir )) {
317344 warning(" Subdirectories are not supported for Bitbucket legacy references. Using repository root." )
318345 }
346+ if (! is.null(parsed $ ref )) {
347+ ref <- paste0(ref , " @" , parsed $ ref )
348+ }
319349 ref
320350 },
321351 # Transparent pass-through for other pak types
322- sprintf(" %s::%s" , parsed $ type , parsed $ original )
352+ if (grepl(paste0(" ^" , parsed $ type , " ::" ), parsed $ original )) {
353+ parsed $ original
354+ } else {
355+ ref <- sprintf(" %s::%s" , parsed $ type , parsed $ original )
356+ if (! is.null(parsed $ ref )) {
357+ ref <- paste0(ref , " @" , parsed $ ref )
358+ }
359+ ref
360+ }
323361 )
324362
325- if (! is.null(parsed $ ref )) {
326- pak_ref <- paste0(pak_ref , " @" , parsed $ ref )
327- }
328-
329363 pak_ref
330364}
331365
@@ -413,7 +447,7 @@ parse_remote_url <- function(url) {
413447 " ci" , " build" , " perf" , " style" , " revert" ,
414448 " renovate" , " dependabot"
415449 )
416- is_version_tag <- grepl(" ^v?\\ d+(\\ Dots +)*([._-][A-Za-z0-9.+-]+)?$" , ref_parts [1 ])
450+ is_version_tag <- grepl(" ^v?\\ d+(\\ . \\ d +)*([._-][A-Za-z0-9.+-]+)?$" , ref_parts [1 ])
417451
418452 if (ref_parts [1 ] %in% common_branches || is_version_tag ) {
419453 ref <- ref_parts [1 ]
0 commit comments