diff --git a/R/install-git.R b/R/install-git.R index 10170b0b..01866352 100644 --- a/R/install-git.R +++ b/R/install-git.R @@ -264,13 +264,18 @@ remote_download.xgit_remote <- function(x, quiet = FALSE) { bundle <- tempfile() - args <- c("clone", "--depth", "1", "--no-hardlinks") + disallows_unadvertised <- grepl("(github|bitbucket)[.]com", tolower(x$url)) + args <- c("clone", if (is.null(x$ref) && disallows_unadvertised) c("--depth", "1"), "--no-hardlinks") args <- c(args, x$args, x$url, bundle) git(paste0(args, collapse = " "), quiet = quiet) if (!is.null(x$ref)) { - git(paste0(c("fetch", "origin", x$ref), collapse = " "), quiet = quiet, path = bundle) - git(paste0(c("checkout", "FETCH_HEAD"), collapse = " "), quiet = quiet, path = bundle) + if (!disallows_unadvertised) { + git(paste0(c("fetch", "origin", x$ref), collapse = " "), quiet = quiet, path = bundle) + git(paste0(c("checkout", "FETCH_HEAD"), collapse = " "), quiet = quiet, path = bundle) + } else { + git(paste0(c("checkout", x$ref), collapse = " "), quiet = quiet, path = bundle) + } } bundle diff --git a/inst/install-github.R b/inst/install-github.R index 460abc06..c92a42fc 100644 --- a/inst/install-github.R +++ b/inst/install-github.R @@ -3682,13 +3682,18 @@ function(...) { bundle <- tempfile() - args <- c("clone", "--depth", "1", "--no-hardlinks") + disallows_unadvertised <- grepl("(github|bitbucket)[.]com", tolower(x$url)) + args <- c("clone", if (is.null(x$ref) && disallows_unadvertised) c("--depth", "1"), "--no-hardlinks") args <- c(args, x$args, x$url, bundle) git(paste0(args, collapse = " "), quiet = quiet) if (!is.null(x$ref)) { - git(paste0(c("fetch", "origin", x$ref), collapse = " "), quiet = quiet, path = bundle) - git(paste0(c("checkout", "FETCH_HEAD"), collapse = " "), quiet = quiet, path = bundle) + if (!disallows_unadvertised) { + git(paste0(c("fetch", "origin", x$ref), collapse = " "), quiet = quiet, path = bundle) + git(paste0(c("checkout", "FETCH_HEAD"), collapse = " "), quiet = quiet, path = bundle) + } else { + git(paste0(c("checkout", x$ref), collapse = " "), quiet = quiet, path = bundle) + } } bundle diff --git a/install-github.R b/install-github.R index 460abc06..c92a42fc 100644 --- a/install-github.R +++ b/install-github.R @@ -3682,13 +3682,18 @@ function(...) { bundle <- tempfile() - args <- c("clone", "--depth", "1", "--no-hardlinks") + disallows_unadvertised <- grepl("(github|bitbucket)[.]com", tolower(x$url)) + args <- c("clone", if (is.null(x$ref) && disallows_unadvertised) c("--depth", "1"), "--no-hardlinks") args <- c(args, x$args, x$url, bundle) git(paste0(args, collapse = " "), quiet = quiet) if (!is.null(x$ref)) { - git(paste0(c("fetch", "origin", x$ref), collapse = " "), quiet = quiet, path = bundle) - git(paste0(c("checkout", "FETCH_HEAD"), collapse = " "), quiet = quiet, path = bundle) + if (!disallows_unadvertised) { + git(paste0(c("fetch", "origin", x$ref), collapse = " "), quiet = quiet, path = bundle) + git(paste0(c("checkout", "FETCH_HEAD"), collapse = " "), quiet = quiet, path = bundle) + } else { + git(paste0(c("checkout", x$ref), collapse = " "), quiet = quiet, path = bundle) + } } bundle