-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add use_r_universe_badge()
#1994
Open
olivroy
wants to merge
7
commits into
r-lib:main
Choose a base branch
from
olivroy:deprec
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jennybc
reviewed
Nov 21, 2024
R/badge.R
Outdated
Comment on lines
154
to
171
check_is_package("use_r_universe_badge()") | ||
# The r-universe link needs the package name + organization. | ||
|
||
pkg <- project_name() | ||
url <- tryCatch(github_url(pkg), error = function(e) NULL) | ||
# in order to get organization | ||
desc <- proj_desc() | ||
urls <- desc$get_urls() | ||
dat <- parse_github_remotes(c(urls, url)) | ||
gh_org <- unique(dat$repo_owner[!is.na(dat$repo_owner)]) | ||
if (length(gh_org) == 0L) { | ||
ui_abort(c( | ||
"{.pkg {pkg}} must have a repo URL in DESCRITPION to create a badge.", | ||
"Use {.fn usethis::use_badge} if you have a different configuration.", | ||
"If {.pkg {pkg}} is on CRAN, you can also see {.url cran.dev/{pkg}} | ||
for a redirect to the r-universe homepage." | ||
)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like a lot a custom code for a task we do elsewhere, even in other badge functions. Seems like target_repo_spec()
is relevant.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
FIx #1883
It has limitations, in the sense that it doesn't verify that the repo actually exists. It would also be great to add the r-universe installation options too.
I could add this to the badge with
ui_code()
It worked out of the box with usethis
implementation considerations
use_badge()
If you want, you can let me know what you think @jeroen. And you'd probably best to implement this function.
ideas
A
browse_r_universe()
similar tobrowse_github()
would probably be useful and easy to implement + the badge could build on top of this.man page preview