-
Notifications
You must be signed in to change notification settings - Fork 89
Use URLs to detect git-like repos rather than name #748
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
Conversation
R/gitlab.R
Outdated
| isGitlabURL <- function(url) { | ||
| is.string(url) && | ||
| grepl("^http(?:s)?://(?:www|api).gitlab.(org|com)", url, perl = TRUE) | ||
| grepl("^(http(?:s)?://)?(www|api)?.?gitlab.(org|com)", url, perl = TRUE) |
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.
I'm not totally sure why the look ahead option didn't work here, but the gitlab.com URL that is in the fixture seemingly required me to do (www|api)?.?
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.
A super-nit here would be to move the . into the pattern, and also properly escape it so it's matching a literal . and not any character. E.g. ((www|api)\\.)?
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.
Ah, yes that's much better
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
R/restore.R
Outdated
| git_remote <- isBitbucketURL(pkgRecord$remote_host) || | ||
| isGitHubURL(pkgRecord$remote_host) || | ||
| isGitlabURL(pkgRecord$remote_host) | ||
| if (git_remote) { | ||
| return(FALSE) | ||
| } |
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.
The main downside is that this will do the wrong thing for users with hosted / enterprise instances of these services, when they're accessible from non-default URLs.
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.
We could also simply look for the presence of remote_host along with maybe remote_repo?
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.
That makes sense to me.
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.
Done! I've also backed out the URL changes (those are probably better / slightly more flexible, but if they aren't needed here I don't want to increase the chance that there's a bug in there that could disrupt other things)
kevinushey
left a comment
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.
LGTM!
karawoo
left a comment
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.
I think it'd be good to add a test case for the remote_host/remote_repo case; otherwise LGTM
Co-authored-by: Kara Woo <karawoo@users.noreply.github.com>
|
Ok, I've added NEWS and will merge in a sec |
I added some unit tests for the
isFromCranlikeRepo()function and ensured that other tests passed (locally at least). I did need to make the URL detectors slightly more flexible to match the test fixtures (though realistically the URLs in the fixtures probably could be updated to be more like real ones instead.resolves #747