Skip to content

Commit 8cf5905

Browse files
committed
more graceful error message handling
1 parent 851bda8 commit 8cf5905

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

R/check_changes_for_autoapproval.R

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ check_changes_for_autoapproval <- function(
2424
# validate inputs
2525
checkmate::assert_string(gh_actor)
2626
checkmate::assert_string(base_hub_path)
27-
checkmate::assert_character(changed_files, min.len = 1)
27+
if (length(changed_files) == 0) {
28+
cli::cli_abort("Empty PRs cannot be autoapproved.")
29+
}
30+
checkmate::assert_character(changed_files)
2831

2932
# tibble of changed files with paths
3033
changed_files_tbl <- tibble::tibble(
@@ -71,22 +74,19 @@ check_changes_for_autoapproval <- function(
7174
dplyr::pull(.data$model_id) |>
7275
unique()
7376

74-
if (length(changed_dirs) == 0) {
75-
cli::cli_abort(
76-
"No valid model directories found in changed files."
77+
# only check authorization if there are model directories
78+
if (length(changed_dirs) > 0) {
79+
cli::cli_inform(
80+
"Checking authorization for {length(changed_dirs)} model director{?y/ies}: {.val {changed_dirs}}"
7781
)
78-
}
7982

80-
cli::cli_inform(
81-
"Checking authorization for {length(changed_dirs)} model director{?y/ies}: {.val {changed_dirs}}"
82-
)
83-
84-
# pass model IDs to check_authorized_users
85-
check_authorized_users(
86-
changed_dirs = changed_dirs,
87-
gh_actor = gh_actor,
88-
base_hub_path = base_hub_path
89-
)
83+
# pass model IDs to check_authorized_users
84+
check_authorized_users(
85+
changed_dirs = changed_dirs,
86+
gh_actor = gh_actor,
87+
base_hub_path = base_hub_path
88+
)
89+
}
9090

9191
invisible()
9292
}

0 commit comments

Comments
 (0)