Skip to content

Commit 49a2726

Browse files
committed
clone_gh_org_repos should respect branch field
1 parent 66c4dc5 commit 49a2726

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

R/packages-json.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,22 @@ clone_gh_org_repos <- function (pkgs_json = NULL, pkgs_dir = NULL) {
213213

214214
out <- pbapply::pblapply (seq_len (nrow (pj)), function (i) {
215215
url <- paste0 ("https://github.com/", pj$orgrepo [i])
216+
branch <- if ("branch" %in% names (pj) && !is.na (pj$branch [i])) pj$branch [i] else NULL
216217
dir_org <- fs::path_dir (pj$path [i])
217218
if (!fs::dir_exists (dir_org)) {
218219
fs::dir_create (dir_org)
219220
}
220221
if (!fs::dir_exists (pj$path [i])) {
221222
withr::with_dir (
222223
dir_org,
223-
gert::git_clone (url)
224+
gert::git_clone (url, branch = branch)
224225
)
225226
} else {
226227
withr::with_dir (
227-
pj$path [i],
228-
gert::git_fetch (verbose = FALSE)
228+
pj$path [i], {
229+
gert::git_fetch (verbose = FALSE)
230+
if (!is.null (branch)) gert::git_branch_checkout (branch)
231+
}
229232
)
230233
}
231234
})

0 commit comments

Comments
 (0)