Skip to content

Commit a132195

Browse files
hadleyjennybc
andauthored
State minimum version for gh and remove conditional code (#1088)
* Remove gh wrapper now that it's not needed * Remove conditional code re: finding pull requests * Fix code for case of "no releases" Zero-length character might be a better return value but downstream code seems to rely on this NULL and I don't feel like pulling this thread * Mention gh minimum version in NEWS Co-authored-by: Jenny Bryan <[email protected]>
1 parent d1d28c9 commit a132195

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Imports:
3030
curl (>= 2.7),
3131
desc,
3232
fs (>= 1.3.0),
33-
gh,
33+
gh (>= 1.1.0),
3434
git2r (>= 0.23),
3535
glue (>= 1.3.0),
3636
purrr,

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@
172172
put a new folder created by `use_course()` or `create_from_github()`
173173
(@malcolmbarrett, #1015).
174174

175+
## Dependency changes
176+
177+
gh minimum version is stated to be v.1.1.0, due to changed behaviour around requests that return nothing.
178+
175179
# usethis 1.5.1
176180

177181
This is a patch release with various small features and bug fixes.

R/github-labels.R

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use_github_labels <- function(repo_spec = github_repo_spec(),
7070
check_github_token(auth_token)
7171

7272
gh <- function(endpoint, ...) {
73-
out <- gh::gh(
73+
gh::gh(
7474
endpoint,
7575
...,
7676
owner = spec_owner(repo_spec),
@@ -81,11 +81,6 @@ use_github_labels <- function(repo_spec = github_repo_spec(),
8181
"Accept" = "application/vnd.github.symmetra-preview+json"
8282
)
8383
)
84-
if (identical(out[[1]], "")) {
85-
list()
86-
} else {
87-
out
88-
}
8984
}
9085

9186
cur_labels <- gh("GET /repos/:owner/:repo/labels")

R/pr.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,14 @@ pr_find <- function(owner,
392392
repo,
393393
pr_owner = owner,
394394
pr_branch = git_branch_name()) {
395-
# Look at all PRs
396395
prs <- gh::gh("GET /repos/:owner/:repo/pulls",
397396
owner = owner,
398397
repo = repo,
399398
.limit = Inf,
400399
.token = check_github_token(allow_empty = TRUE)
401400
)
402401

403-
# prs has length zero if gh >= v1.1.0 and is "" for earlier versions
404-
if (length(prs) < 1 || identical(prs[[1]], "")) {
402+
if (length(prs) < 1) {
405403
return(character())
406404
}
407405

R/tidyverse.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ releases <- function(repo_spec = github_repo_spec()) {
366366
owner = spec_owner(repo_spec),
367367
repo = spec_repo(repo_spec)
368368
)
369-
if (identical(res[[1]], "")) return(NULL)
369+
if (length(res) < 1) {
370+
return(NULL)
371+
}
370372
pluck_chr(res, "tag_name")
371373
}
372374

0 commit comments

Comments
 (0)