You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not really sure if this make what you want, I'm relatively new to R and I'm not sure what inherits and the "{username}" and "{repo}" to pass arguments to functions really do. I try to maintain the format of the function, however at the bottom of the comment is what I would write in my package.
Solution 1 trying to maintain the function in the same format as yours:
#' Determine whether the repo already exists#' @param username account name#' @param repo repo name#' @details very much inspired by available::available_on_github()#' @noRdrepo_exists<-function(username, repo) {
check_repo<-function(username, repo) {
# Check repository in the API where all the packages are listedres<-jsonlite::fromJSON("http://rpkg-api.gepuro.net/rpkg?q={username}/{name}")
# Check exactly that the repository exists on github
any(res$url=="https://github.com/{username}/{name}.git")
}
!inherits(
try(check_repo(
username=username,
repo=repo
),
silent=TRUE
),
"try-error"
)
}
Solution 2 as I would do it:
#' Determine whether the repo already exists#' @param username account name#' @param repo repo name#' @details very much inspired by available::available_on_github()#' @noRdrepo_exists<-function(username, repo) {
# Check repository in the API where all the packages are listedres<-jsonlite::fromJSON(paste0("http://rpkg-api.gepuro.net/rpkg?q=",username,"/",repo))
# Check exactly that the repository exists on github
any(res$url=="https://github.com/{username}/{name}.git")
}
Hope it helps.
EDIT 1 && 2: sorry, first comment on github and didn't know how to highlight code
EDIT 3: Function can be changed easily to give information about if only the username or only the package exists and give an error message saying if the user should change only his/her username or only the name of his/her package
Currently,
repo_exists
will returnFALSE
if there's no repo with the same name for the account... but also if there's something wrong with the API.The text was updated successfully, but these errors were encountered: