Skip to content

Commit afd1a71

Browse files
committed
Ensure code works if no labels
1 parent c1a5d17 commit afd1a71

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

R/github-labels.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ use_github_labels <- function(delete_default = FALSE,
2929
labels <- gh("GET /repos/:owner/:repo/labels")
3030

3131
# Add missing labels
32-
cur_labels <- vapply(labels, "[[", "name", FUN.VALUE = character(1))
32+
if (identical(labels[[1]], "")) {
33+
cur_labels <- character()
34+
} else {
35+
cur_labels <- vapply(labels, "[[", "name", FUN.VALUE = character(1))
36+
}
3337
new_labels <- setdiff(names(gh_labels), cur_labels)
3438
if (length(new_labels) > 0) {
3539
done("Adding missing labels: ", collapse(value(new_labels)))
@@ -44,7 +48,11 @@ use_github_labels <- function(delete_default = FALSE,
4448
}
4549

4650
# Correct bad colours
47-
cur_cols <- vapply(labels, "[[", "color", FUN.VALUE = character(1))
51+
if (identical(labels[[1]], "")) {
52+
cur_cols <- character()
53+
} else {
54+
cur_cols <- vapply(labels, "[[", "color", FUN.VALUE = character(1))
55+
}
4856
tru_cols <- gh_labels[cur_labels]
4957
col_labels <- cur_labels[!is.na(tru_cols) & tru_cols != cur_cols]
5058

0 commit comments

Comments
 (0)