Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Authors@R: c(
person("Nikolas", "Burkoff", email = "nikolas.burkoff@roche.com", role = "aut")
)
Imports:
checkmate,
desc,
devtools,
digest,
Expand Down Expand Up @@ -51,6 +52,7 @@ Collate:
'dependencies.R'
'dependencies_app.R'
'dependencies_helper.R'
'fnc_deps.R'
'git_tools.R'
'graph_methods.R'
'host.R'
Expand Down
10 changes: 9 additions & 1 deletion R/caching.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ copy_local_repo_to_cachedir <- function(local_dir, repo, host, select_ref_rule,
branch_flag = "local"
)
ref <- select_ref_rule(available_refs)
stopifnot(ref %in% available_refs$ref)

# Better safenet for missing branch
Comment thread
Melkiades marked this conversation as resolved.
Outdated
if (!(ref %in% available_refs$ref)) {
stop("Reference branch ", ref,
" not found between the available ones in repo directory: ",
repo_dir) # nocov
}

if (ref != get_current_branch(repo_dir)) {
# if ref is a branch and you are on the wrong branch throw error
Expand All @@ -147,6 +153,7 @@ copy_local_repo_to_cachedir <- function(local_dir, repo, host, select_ref_rule,
}
}

# If there is something left unstaged or uncommitted it does it for you (should it?)
if ((length(git2r::status(repo_dir)$staged) > 0) ||
(length(git2r::status(repo_dir)$unstaged) > 0) ||
(length(git2r::status(repo_dir)$untracked) > 0)) {
Expand Down Expand Up @@ -272,6 +279,7 @@ rec_checkout_internal_deps <- function(repos_to_process, ref,
verbose = verbose
)
} else {
# Case some local repos were not specified
repo_info <- checkout_repo(
get_repo_cache_dir(repo_and_host$repo, repo_and_host$host),
get_repo_url(repo_and_host$repo, repo_and_host$host),
Expand Down
22 changes: 16 additions & 6 deletions R/dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
# todo: local_repos to data.frame: package name to directory: no, because this means that the package needs to be fetched from the remote first
# todo? unlink(get_packages_cache_dir(), recursive = TRUE); dir.create(get_packages_cache_dir())

# Helper function copied from fs internals
is_windows <- function() {
if (isTRUE(Sys.getenv("FS_IS_WINDOWS", "FALSE") == "TRUE")) {
return(TRUE)
}
tolower(Sys.info()[["sysname"]]) == "windows"
}
Comment on lines +7 to +13

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This in theory could check if on windows to solve #177


#' Create dependency structure of your package collection
#' @param project (`character`) If `project_type` is `local` then
Expand Down Expand Up @@ -76,12 +83,15 @@ dependency_table <- function(project = ".",
verbose = 1) {

# validate arguments
stopifnot(is.data.frame(local_repos) || is.null(local_repos))
check_verbose_arg(verbose)
checkmate::assert_data_frame(local_repos, null.ok = TRUE)
checkmate::assert_int(verbose, lower = 0, upper = 2)
direction <- check_direction_arg_deprecated(direction)
check_direction_arg(direction)
stopifnot(project_type %in% c("local", "repo@host"))
stopifnot(rlang::is_scalar_character(fallback_branch))
checkmate::assert_choice(project_type, c("local", "repo@host"))
checkmate::assert_character(fallback_branch, max.len = 1)

# Ideally here we could catch the error for windows and too long paths
# if (is_windows())

if (project_type == "repo@host" && (is.null(ref) || nchar(ref) == 0)) {
stop("For non-local projects the (branch/tag) must be specified")
Expand Down Expand Up @@ -112,12 +122,12 @@ dependency_table <- function(project = ".",
repo_to_process <- list(parse_remote_project(project))
}


# a dataframe with columns repo, host, ref, sha, cache_dir, accessible (logical)
internal_deps <- rec_checkout_internal_deps(
repo_to_process, ref,
direction = direction,
local_repos = local_repos, fallback_branch = fallback_branch,
local_repos = local_repos,
fallback_branch = fallback_branch,
verbose = verbose
)

Expand Down
Loading